Compare commits

..

No commits in common. "0f19bd77cda1fa89df618b02aa2231ff01930d6e" and "536acc06ee7f0fa0c7e69a16bb2640e3a25e4d9e" have entirely different histories.

8 changed files with 49 additions and 72 deletions

View File

@ -1,18 +1,18 @@
import {ComponentFixture, TestBed} from '@angular/core/testing'; import {ComponentFixture, TestBed} from '@angular/core/testing';
import {FooterComponent} from './footer.component'; import {FooterComponent} from './footer.component';
import {RouterTestingModule} from '@angular/router/testing'; import {RouterTestingModule} from "@angular/router/testing";
import {AppComponent} from '../../app.component'; import {AppComponent} from "../../app.component";
import {ImprintComponent} from '../../pages/imprint/imprint.component'; import {ImprintComponent} from "../../pages/imprint/imprint.component";
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from "@angular/router";
describe('FooterComponent', () => { describe('FooterComponent', () => {
let component: FooterComponent; let component: FooterComponent;
let fixture: ComponentFixture<FooterComponent>; let fixture: ComponentFixture<FooterComponent>;
const router = { let router = {
navigate: jasmine.createSpy('navigate'), navigate: jasmine.createSpy('navigate'),
routerState: jasmine.createSpy('routerState') routerState: jasmine.createSpy('routerState')
}; }
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({

View File

@ -1,22 +1,21 @@
import {ComponentFixture, TestBed} from '@angular/core/testing'; import {ComponentFixture, TestBed} from '@angular/core/testing';
import {HeaderComponent} from './header.component'; import {HeaderComponent} from './header.component';
import {RouterTestingModule} from '@angular/router/testing'; import {RouterTestingModule} from "@angular/router/testing";
import {MatMenuModule} from '@angular/material/menu'; import {MatMenuModule} from "@angular/material/menu";
import {Router} from '@angular/router'; import {Router} from "@angular/router";
describe('HeaderComponent', () => { describe('HeaderComponent', () => {
let component: HeaderComponent; let component: HeaderComponent;
let fixture: ComponentFixture<HeaderComponent>; let fixture: ComponentFixture<HeaderComponent>;
const router = { let router = {
navigate: jasmine.createSpy('navigate'), navigate: jasmine.createSpy('navigate'),
navigateByUrl: (url: string) => { navigateByUrl: (url: string) => {
return { return {
then: () => { then: () => {}
}
} }
};
} }
};
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({

View File

@ -1,19 +1,18 @@
import {ComponentFixture, TestBed} from '@angular/core/testing'; import {ComponentFixture, TestBed} from '@angular/core/testing';
import {NewestPricesListComponent} from './newest-prices-list.component'; import {NewestPricesListComponent} from './newest-prices-list.component';
import {RouterTestingModule} from '@angular/router/testing'; import {RouterTestingModule} from "@angular/router/testing";
import {HttpClient} from '@angular/common/http'; import {HttpClient} from "@angular/common/http";
import {AbstractMockObservableService} from '../../mocks/mock.service'; import {AbstractMockObservableService} from "../../mocks/mock.service";
import {ApiService} from '../../services/api.service'; import {ApiService} from "../../services/api.service";
import {Observable} from 'rxjs';
class MockApiService extends AbstractMockObservableService { class MockApiService extends AbstractMockObservableService {
getCurrentPricePerVendor(): any { getCurrentPricePerVendor() {
this.content = []; this.content = [];
return this; return this;
} }
getVendors(): any { getVendors() {
const vendor = { const vendor = {
vendor_id: 1, vendor_id: 1,
name: 'Max Mustermann', name: 'Max Mustermann',

View File

@ -1,33 +1,18 @@
import {ComponentFixture, TestBed} from '@angular/core/testing'; import {ComponentFixture, TestBed} from '@angular/core/testing';
import {ProductDetailsComponent} from './product-details.component'; import {ProductDetailsComponent} from './product-details.component';
import {RouterTestingModule} from '@angular/router/testing'; import {RouterTestingModule} from "@angular/router/testing";
import {AbstractMockObservableService} from '../../mocks/mock.service'; import {AbstractMockObservableService} from "../../mocks/mock.service";
import {ApiService} from '../../services/api.service'; import {ApiService} from "../../services/api.service";
import {ChartComponent, NgApexchartsModule} from 'ng-apexcharts'; import {ChartComponent, NgApexchartsModule} from "ng-apexcharts";
import {By} from '@angular/platform-browser';
class MockApiService extends AbstractMockObservableService { class MockApiService extends AbstractMockObservableService {
getProduct(): any { getProduct() {
const product = { this.content = {};
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; return this;
} }
getLowestPrices(): any { getLowestPrices() {
const price = { const price = {
price_id: 1, price_id: 1,
product_id: 1, product_id: 1,
@ -39,12 +24,12 @@ class MockApiService extends AbstractMockObservableService {
return this; return this;
} }
getAmazonPrice(): any { getAmazonPrice() {
this.content = {}; this.content = {};
return this; return this;
} }
getVendors(): any { getVendors() {
const vendor = { const vendor = {
vendor_id: 1, vendor_id: 1,
name: 'Max Mustermann', name: 'Max Mustermann',
@ -54,7 +39,7 @@ class MockApiService extends AbstractMockObservableService {
country_code: 'DE', country_code: 'DE',
phone: '+49 123 4567890', phone: '+49 123 4567890',
website: 'https://www.amazon.de', website: 'https://www.amazon.de',
}; }
this.content = [vendor]; this.content = [vendor];
return this; return this;
} }
@ -87,10 +72,4 @@ describe('ProductDetailsComponent', () => {
it('should create', () => { it('should create', () => {
expect(component).toBeTruthy(); 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');
});
}); });

View File

@ -1,20 +1,20 @@
import {ComponentFixture, TestBed} from '@angular/core/testing'; import {ComponentFixture, TestBed} from '@angular/core/testing';
import {ProductListComponent} from './product-list.component'; import {ProductListComponent} from './product-list.component';
import {FooterComponent} from '../footer/footer.component'; import {FooterComponent} from "../footer/footer.component";
import {HeaderComponent} from '../header/header.component'; import {HeaderComponent} from "../header/header.component";
import {RouterTestingModule} from '@angular/router/testing'; import {RouterTestingModule} from "@angular/router/testing";
import {ApiService} from '../../services/api.service'; import {ApiService} from "../../services/api.service";
import {AbstractMockObservableService} from '../../mocks/mock.service'; import {AbstractMockObservableService} from "../../mocks/mock.service";
import {Router} from '@angular/router'; import {Router} from "@angular/router";
class MockApiService extends AbstractMockObservableService { class MockApiService extends AbstractMockObservableService {
getProducts(): any { getProducts() {
this.content = []; this.content = [];
return this; return this;
} }
getProductsByQuery(): any { getProductsByQuery() {
this.content = []; this.content = [];
return this; return this;
} }
@ -24,10 +24,10 @@ describe('ProductListComponent', () => {
let component: ProductListComponent; let component: ProductListComponent;
let fixture: ComponentFixture<ProductListComponent>; let fixture: ComponentFixture<ProductListComponent>;
let mockService; let mockService;
const router = { let router = {
navigate: jasmine.createSpy('navigate'), navigate: jasmine.createSpy('navigate'),
routerState: jasmine.createSpy('routerState') routerState: jasmine.createSpy('routerState')
}; }
beforeEach(async () => { beforeEach(async () => {
mockService = new MockApiService(); mockService = new MockApiService();
@ -71,7 +71,7 @@ describe('ProductListComponent', () => {
manufacturer_id: 1, manufacturer_id: 1,
selling_rank: '1', selling_rank: '1',
category_id: 1 category_id: 1
}; }
component.clickedProduct(product); component.clickedProduct(product);
expect(router.navigate).toHaveBeenCalledWith(['/product/1']); expect(router.navigate).toHaveBeenCalledWith(['/product/1']);

View File

@ -1,16 +1,16 @@
import {ComponentFixture, TestBed} from '@angular/core/testing'; import {ComponentFixture, TestBed} from '@angular/core/testing';
import {LandingpageComponent} from './landingpage.component'; import {LandingpageComponent} from './landingpage.component';
import {RouterTestingModule} from '@angular/router/testing'; import {RouterTestingModule} from "@angular/router/testing";
import {Router} from '@angular/router'; import {Router} from "@angular/router";
describe('LandingpageComponent', () => { describe('LandingpageComponent', () => {
let component: LandingpageComponent; let component: LandingpageComponent;
let fixture: ComponentFixture<LandingpageComponent>; let fixture: ComponentFixture<LandingpageComponent>;
const router = { let router = {
navigate: jasmine.createSpy('navigate'), navigate: jasmine.createSpy('navigate'),
routerState: jasmine.createSpy('routerState') routerState: jasmine.createSpy('routerState')
}; }
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({

View File

@ -1,7 +1,7 @@
import {ComponentFixture, TestBed} from '@angular/core/testing'; import {ComponentFixture, TestBed} from '@angular/core/testing';
import {ProductDetailPageComponent} from './product-detail-page.component'; import {ProductDetailPageComponent} from './product-detail-page.component';
import {RouterTestingModule} from '@angular/router/testing'; import {RouterTestingModule} from "@angular/router/testing";
describe('ProductDetailPageComponent', () => { describe('ProductDetailPageComponent', () => {
let component: ProductDetailPageComponent; let component: ProductDetailPageComponent;

View File

@ -1,10 +1,10 @@
import {ComponentFixture, TestBed} from '@angular/core/testing'; import {ComponentFixture, TestBed} from '@angular/core/testing';
import {ProductSearchPageComponent} from './product-search-page.component'; import {ProductSearchPageComponent} from './product-search-page.component';
import {HeaderComponent} from '../../components/header/header.component'; import {HeaderComponent} from "../../components/header/header.component";
import {FooterComponent} from '../../components/footer/footer.component'; import {FooterComponent} from "../../components/footer/footer.component";
import {ProductListComponent} from '../../components/product-list/product-list.component'; import {ProductListComponent} from "../../components/product-list/product-list.component";
import {RouterTestingModule} from '@angular/router/testing'; import {RouterTestingModule} from "@angular/router/testing";
describe('ProductSearchPageComponent', () => { describe('ProductSearchPageComponent', () => {
let component: ProductSearchPageComponent; let component: ProductSearchPageComponent;