mirror of
https://github.com/Mueller-Patrick/Betterzon.git
synced 2026-04-27 15:50:11 +00:00
BETTERZON-89: Refactoring / Reformatting and adding unit tests (#41)
This commit is contained in:
@@ -1,18 +1,33 @@
|
||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {ProductDetailsComponent} from './product-details.component';
|
||||
import {RouterTestingModule} from "@angular/router/testing";
|
||||
import {AbstractMockObservableService} from "../../mocks/mock.service";
|
||||
import {ApiService} from "../../services/api.service";
|
||||
import {ChartComponent, NgApexchartsModule} from "ng-apexcharts";
|
||||
import {RouterTestingModule} from '@angular/router/testing';
|
||||
import {AbstractMockObservableService} from '../../mocks/mock.service';
|
||||
import {ApiService} from '../../services/api.service';
|
||||
import {ChartComponent, NgApexchartsModule} from 'ng-apexcharts';
|
||||
import {By} from '@angular/platform-browser';
|
||||
|
||||
class MockApiService extends AbstractMockObservableService {
|
||||
getProduct() {
|
||||
this.content = {};
|
||||
getProduct(): any {
|
||||
const product = {
|
||||
product_id: 1,
|
||||
asin: 'ASIN',
|
||||
is_active: true,
|
||||
name: 'Super tolles Produkt',
|
||||
short_description: 'Descr',
|
||||
long_description: 'Descr',
|
||||
image_guid: '123',
|
||||
date_added: new Date(),
|
||||
last_modified: new Date(),
|
||||
manufacturer_id: 1,
|
||||
selling_rank: '1',
|
||||
category_id: 1
|
||||
};
|
||||
this.content = product;
|
||||
return this;
|
||||
}
|
||||
|
||||
getLowestPrices() {
|
||||
getLowestPrices(): any {
|
||||
const price = {
|
||||
price_id: 1,
|
||||
product_id: 1,
|
||||
@@ -24,12 +39,12 @@ class MockApiService extends AbstractMockObservableService {
|
||||
return this;
|
||||
}
|
||||
|
||||
getAmazonPrice() {
|
||||
getAmazonPrice(): any {
|
||||
this.content = {};
|
||||
return this;
|
||||
}
|
||||
|
||||
getVendors() {
|
||||
getVendors(): any {
|
||||
const vendor = {
|
||||
vendor_id: 1,
|
||||
name: 'Max Mustermann',
|
||||
@@ -39,7 +54,7 @@ class MockApiService extends AbstractMockObservableService {
|
||||
country_code: 'DE',
|
||||
phone: '+49 123 4567890',
|
||||
website: 'https://www.amazon.de',
|
||||
}
|
||||
};
|
||||
this.content = [vendor];
|
||||
return this;
|
||||
}
|
||||
@@ -72,4 +87,10 @@ describe('ProductDetailsComponent', () => {
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should show the product name', () => {
|
||||
component.ngOnInit();
|
||||
const title = fixture.debugElement.query(By.css('.productTitle'));
|
||||
expect(title.nativeElement.innerText).toEqual('Super tolles Produkt');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user