blob: 4b572e054a93ab449ebc56c7e93a6cc8886c19eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import {PackagesHeaderComponent} from './packages-header.component';
import {PackagesStore} from '../../packages.store';
import {BrowserDynamicTestingModule, platformBrowserDynamicTesting} from '@angular/platform-browser-dynamic/testing';
import {PackagesDashboardState} from '../../model/packages-dashboard.state';
import {getBlueprintPageMock} from '../../blueprint.page.mock';
import {of} from 'rxjs';
import {By} from '@angular/platform-browser';
fdescribe('PackagesHeaderComponent', () => {
let component: PackagesHeaderComponent;
let fixture: ComponentFixture<PackagesHeaderComponent>;
let packageStoreStub: Partial<PackagesStore>;
let packageDashboardState;
beforeEach(() => {
packageDashboardState = new PackagesDashboardState();
packageDashboardState.totalPackagesWithoutSearchorFilters = 9;
packageStoreStub = {state$: of(packageDashboardState)};
TestBed.resetTestEnvironment();
TestBed.initTestEnvironment(BrowserDynamicTestingModule,
platformBrowserDynamicTesting());
TestBed.configureTestingModule({
declarations: [PackagesHeaderComponent],
providers: [
{provide: PackagesStore, useValue: packageStoreStub}
]
});
});
beforeEach(() => {
fixture = TestBed.createComponent(PackagesHeaderComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should display the number of packages', () => {
component.numberOfPackages = 10;
const numberOfPackage = fixture.debugElement.query(By.css('#numberOfPackages'));
const numberOfPackageElement: HTMLElement = numberOfPackage.nativeElement;
fixture.detectChanges();
expect(numberOfPackageElement.textContent).toContain('' + 10);
});
it('should equals number of packages at store ', async(() => {
packageDashboardState.totalPackagesWithoutSearchorFilters = 17;
packageStoreStub = {state$: of(packageDashboardState)};
fixture = TestBed.createComponent(PackagesHeaderComponent);
component = fixture.componentInstance;
fixture.detectChanges();
const numberOfPackage = fixture.debugElement.query(By.css('#numberOfPackages'));
const numberOfPackageElement: HTMLElement = numberOfPackage.nativeElement;
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(numberOfPackageElement.textContent).toContain('' + 17);
});
}));
});
|