diff options
author | 2020-01-20 12:46:24 +0200 | |
---|---|---|
committer | 2020-01-22 13:54:18 +0000 | |
commit | 0e5c78cec1e1b1ce4d1f6488f6264ca1daffef58 (patch) | |
tree | 52795314e2228f7a18a26194bc727158ff977d4b /cds-ui/designer-client/src/app/modules/feature-modules/packages/packages-dashboard/packages-header/packages-header.component.spec.ts | |
parent | 87d9d1ffac42c4d1d3983445eb0f531db79dd34a (diff) |
fixining compilation in unit testing
add unit test for package-header.component
Issue-ID: CCSDK-2032
Change-Id: I459ee690b84ae7eb7a852c6dc65fe1702fb6bf4a
Signed-off-by: shaaban Altanany <shaaban.eltanany.ext@orange.com>
Diffstat (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/packages/packages-dashboard/packages-header/packages-header.component.spec.ts')
-rw-r--r-- | cds-ui/designer-client/src/app/modules/feature-modules/packages/packages-dashboard/packages-header/packages-header.component.spec.ts | 89 |
1 files changed, 65 insertions, 24 deletions
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/packages-dashboard/packages-header/packages-header.component.spec.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/packages-dashboard/packages-header/packages-header.component.spec.ts index 06a09e851..39228af76 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/packages-dashboard/packages-header/packages-header.component.spec.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/packages-dashboard/packages-header/packages-header.component.spec.ts @@ -1,25 +1,66 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { PackagesHeaderComponent } from './packages-header.component'; - -describe('PackagesHeaderComponent', () => { - let component: PackagesHeaderComponent; - let fixture: ComponentFixture<PackagesHeaderComponent>; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ PackagesHeaderComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(PackagesHeaderComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); +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); + }); + + })); + }); |