Skip to content

Commit a3ad9a1

Browse files
authored
Improve the Tests for nested wizard steps (#272)
- add a more fitting description - add some content to the steps in the wizard under test - add some checks that compare the actual wizard steps against the detected steps
1 parent 9855787 commit a3ad9a1

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

src/lib/components/wizard.component-nested-steps.spec.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,47 @@ import { Component, ViewChild } from '@angular/core';
22
import { async, ComponentFixture, TestBed, tick, fakeAsync } from '@angular/core/testing';
33
import { ArchwizardModule } from '../archwizard.module';
44
import { WizardComponent } from './wizard.component';
5+
import { WizardStep } from '../util/wizard-step.interface';
56

67
@Component({
78
selector: 'aw-test-wizard',
89
template: `
910
<aw-wizard>
1011
<div>
11-
<aw-wizard-step></aw-wizard-step>
12+
<aw-wizard-step #firstStep stepTitle='Steptitle 1'>
13+
Step 1
14+
</aw-wizard-step>
1215
</div>
1316
<div>
14-
<aw-wizard-step></aw-wizard-step>
17+
<aw-wizard-step #secondStep stepTitle='Steptitle 2'>
18+
Step 2
19+
</aw-wizard-step>
1520
</div>
1621
<div>
1722
<div>
18-
<aw-wizard-step></aw-wizard-step>
23+
<aw-wizard-step #thirdStep stepTitle='Steptitle 3'>
24+
Step 3
25+
</aw-wizard-step>
1926
</div>
2027
</div>
2128
</aw-wizard>
2229
`
2330
})
2431
class WizardTestComponent {
25-
@ViewChild(WizardComponent) public wizard: WizardComponent;
32+
@ViewChild(WizardComponent)
33+
public wizard: WizardComponent;
34+
35+
@ViewChild('firstStep')
36+
public first: WizardStep;
37+
38+
@ViewChild('secondStep')
39+
public second: WizardStep;
40+
41+
@ViewChild('thirdStep')
42+
public third: WizardStep;
2643
}
2744

28-
describe('WizardComponent', () => {
45+
describe('WizardComponent with nested steps', () => {
2946
let wizardTestFixture: ComponentFixture<WizardTestComponent>;
3047

3148
let wizardTest: WizardTestComponent;
@@ -57,5 +74,9 @@ describe('WizardComponent', () => {
5774

5875
it('should contain 3 steps', () => {
5976
expect(wizard.wizardSteps.length).toBe(3);
77+
78+
expect(wizardTest.first).toBe(wizard.wizardSteps[0]);
79+
expect(wizardTest.second).toBe(wizard.wizardSteps[1]);
80+
expect(wizardTest.third).toBe(wizard.wizardSteps[2]);
6081
});
6182
});

0 commit comments

Comments
 (0)