|
1 | 1 | /* tslint:disable:no-unused-variable */ |
2 | | -import {async, ComponentFixture, TestBed} from '@angular/core/testing'; |
3 | | -import {DebugElement, QueryList} from '@angular/core'; |
| 2 | +import {async, ComponentFixture, TestBed} from "@angular/core/testing"; |
| 3 | +import {QueryList, ViewChild, Component, ContentChild, OnInit} from "@angular/core"; |
| 4 | +import {WizardNavigationBarComponent} from "./wizard-navigation-bar.component"; |
| 5 | +import {WizardComponent} from "./wizard.component"; |
| 6 | +import {WizardStepComponent} from "./wizard-step.component"; |
| 7 | +import {GoToStepDirective} from "../directives/go-to-step.directive"; |
| 8 | +import {By} from "@angular/platform-browser"; |
4 | 9 |
|
5 | | -import {WizardNavigationBarComponent} from './wizard-navigation-bar.component'; |
6 | | -import {WizardComponent} from './wizard.component'; |
7 | | -import {WizardStepComponent} from './wizard-step.component'; |
8 | | -import {GoToStepDirective} from '../directives/go-to-step.directive'; |
| 10 | +@Component({ |
| 11 | + selector: 'test-wizard', |
| 12 | + template: ` |
| 13 | + <wizard> |
| 14 | + <wizard-step title='Steptitle 1'>Step 1</wizard-step> |
| 15 | + <wizard-step title='Steptitle 2'>Step 2</wizard-step> |
| 16 | + <wizard-step title='Steptitle 3'>Step 3</wizard-step> |
| 17 | + </wizard> |
| 18 | + ` |
| 19 | +}) |
| 20 | +class WizardTestComponent { |
| 21 | + @ViewChild(WizardComponent) |
| 22 | + public wizard: WizardComponent; |
| 23 | +} |
9 | 24 |
|
10 | 25 | describe('WizardNavigationBarComponent', () => { |
11 | | - let component: WizardNavigationBarComponent; |
12 | | - let fixture: ComponentFixture<WizardNavigationBarComponent>; |
| 26 | + let wizardTest: WizardTestComponent; |
| 27 | + let wizardTestFixture: ComponentFixture<WizardTestComponent>; |
13 | 28 |
|
14 | 29 | beforeEach(async(() => { |
15 | | - let wizard = new WizardComponent(); |
16 | | - |
17 | | - wizard.wizardSteps = new QueryList<WizardStepComponent>(); |
18 | | - |
19 | 30 | TestBed.configureTestingModule({ |
20 | | - declarations: [WizardNavigationBarComponent, WizardComponent, WizardStepComponent, GoToStepDirective], |
21 | | - providers: [{ provide: WizardComponent, useValue: wizard }] |
| 31 | + declarations: [ WizardComponent, WizardStepComponent, WizardNavigationBarComponent, WizardTestComponent, GoToStepDirective ] |
22 | 32 | }) |
23 | 33 | .compileComponents(); |
24 | 34 | })); |
25 | 35 |
|
26 | 36 | beforeEach(() => { |
27 | | - fixture = TestBed.createComponent(WizardNavigationBarComponent); |
28 | | - component = fixture.componentInstance; |
29 | | - fixture.detectChanges(); |
| 37 | + wizardTestFixture = TestBed.createComponent(WizardTestComponent); |
| 38 | + wizardTest = wizardTestFixture.componentInstance; |
| 39 | + wizardTestFixture.detectChanges(); |
30 | 40 | }); |
31 | 41 |
|
32 | 42 | it('should create', () => { |
33 | | - expect(component).toBeTruthy(); |
| 43 | + expect(wizardTest).toBeTruthy(); |
| 44 | + expect(wizardTestFixture.debugElement.query(By.css('wizard-navigation-bar'))).toBeTruthy(); |
34 | 45 | }); |
35 | 46 | }); |
0 commit comments