-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SHIBUI-331 Implemented unsaved changes modal and tests
- Loading branch information
Showing
7 changed files
with
169 additions
and
9 deletions.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
ui/src/app/metadata/provider/component/unsaved-provider.dialog.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import { Component, ViewChild } from '@angular/core'; | ||
| import { TestBed, async, ComponentFixture} from '@angular/core/testing'; | ||
| import { RouterTestingModule } from '@angular/router/testing'; | ||
| import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; | ||
| import { SharedModule } from '../../../shared/shared.module'; | ||
| import { UnsavedProviderComponent } from './unsaved-provider.dialog'; | ||
| import { NgbActiveModalStub } from '../../../../testing/modal.stub'; | ||
|
|
||
| @Component({ | ||
| template: ` | ||
| <unsaved-provider></unsaved-provider> | ||
| ` | ||
| }) | ||
| class TestHostComponent { | ||
| @ViewChild(UnsavedProviderComponent) | ||
| public componentUnderTest: UnsavedProviderComponent; | ||
| } | ||
|
|
||
| describe('Unsaved Provider Dialog Component', () => { | ||
|
|
||
| let fixture: ComponentFixture<TestHostComponent>; | ||
| let instance: TestHostComponent; | ||
| let cmp: UnsavedProviderComponent; | ||
|
|
||
| beforeEach(async(() => { | ||
| TestBed.configureTestingModule({ | ||
| imports: [], | ||
| declarations: [ | ||
| UnsavedProviderComponent, | ||
| TestHostComponent | ||
| ], | ||
| providers: [ | ||
| { provide: NgbActiveModal, useClass: NgbActiveModalStub } | ||
| ] | ||
| }).compileComponents(); | ||
|
|
||
| fixture = TestBed.createComponent(TestHostComponent); | ||
| instance = fixture.componentInstance; | ||
| cmp = instance.componentUnderTest; | ||
| fixture.detectChanges(); | ||
| })); | ||
|
|
||
| it('should instantiate the component', async(() => { | ||
| expect(cmp).toBeTruthy(); | ||
| })); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import { Component, ViewChild } from '@angular/core'; | ||
| import { TestBed, async, ComponentFixture } from '@angular/core/testing'; | ||
| import { RouterTestingModule } from '@angular/router/testing'; | ||
| import { StoreModule, Store, combineReducers } from '@ngrx/store'; | ||
|
|
||
| import * as fromWizard from '../reducer'; | ||
| import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'; | ||
| import { WizardComponent, ICONS } from './wizard.component'; | ||
|
|
||
| @Component({ | ||
| template: ` | ||
| <wizard></wizard> | ||
| ` | ||
| }) | ||
| class TestHostComponent { | ||
| @ViewChild(WizardComponent) | ||
| public componentUnderTest: WizardComponent; | ||
| } | ||
|
|
||
| describe('Wizard Component', () => { | ||
|
|
||
| let fixture: ComponentFixture<TestHostComponent>; | ||
| let instance: TestHostComponent; | ||
| let app: WizardComponent; | ||
| let store: Store<fromWizard.State>; | ||
|
|
||
| beforeEach(async(() => { | ||
| TestBed.configureTestingModule({ | ||
| imports: [ | ||
| NgbDropdownModule.forRoot(), | ||
| RouterTestingModule, | ||
| StoreModule.forRoot({ | ||
| wizard: combineReducers(fromWizard.reducers) | ||
| }) | ||
| ], | ||
| declarations: [ | ||
| WizardComponent, | ||
| TestHostComponent | ||
| ], | ||
| }).compileComponents(); | ||
|
|
||
| store = TestBed.get(Store); | ||
| spyOn(store, 'dispatch'); | ||
|
|
||
| fixture = TestBed.createComponent(TestHostComponent); | ||
| instance = fixture.componentInstance; | ||
| app = instance.componentUnderTest; | ||
| fixture.detectChanges(); | ||
| })); | ||
|
|
||
| it('should compile without error', () => { | ||
| expect(app).toBeTruthy(); | ||
| }); | ||
|
|
||
| describe('getIcon method', () => { | ||
| it('should return the check string for the last index', () => { | ||
| expect(app.getIcon({ index: 'foo' }, { index: 'foo' })).toEqual(ICONS.CHECK); | ||
| }); | ||
| it('should return the index icon for other indexes', () => { | ||
| expect(app.getIcon({ index: 'foo' }, { index: 'bar' })).toEqual(ICONS.INDEX); | ||
| expect(app.getIcon({ index: 'foo' }, null)).toEqual(ICONS.INDEX); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters