11import { async , ComponentFixture , fakeAsync , TestBed , tick } from '@angular/core/testing' ;
2- import { Component , ViewChild } from '@angular/core' ;
2+ import { Component , DebugElement , ViewChild } from '@angular/core' ;
33import { WizardNavigationBarComponent } from './wizard-navigation-bar.component' ;
44import { WizardComponent } from './wizard.component' ;
55import { By } from '@angular/platform-browser' ;
@@ -11,15 +11,17 @@ import {WizardState} from '../navigation/wizard-state.model';
1111 selector : 'aw-test-wizard' ,
1212 template : `
1313 <aw-wizard>
14- <aw-wizard-step stepTitle='Steptitle 1'>Step 1</aw-wizard-step>
14+ <aw-wizard-step stepTitle='Steptitle 1' [stepId]="firstStepId" >Step 1</aw-wizard-step>
1515 <aw-wizard-step stepTitle='Steptitle 2' awOptionalStep>Step 2</aw-wizard-step>
1616 <aw-wizard-step stepTitle='Steptitle 3'>Step 3</aw-wizard-step>
1717 </aw-wizard>
1818 `
1919} )
2020class WizardTestComponent {
21+ public firstStepId = 'step1' ;
22+
2123 @ViewChild ( WizardComponent )
22- wizard : WizardComponent ;
24+ public wizard : WizardComponent ;
2325}
2426
2527describe ( 'WizardNavigationBarComponent' , ( ) => {
@@ -459,8 +461,10 @@ describe('WizardNavigationBarComponent', () => {
459461 it ( 'should use the \"small\" layout when no navigation bar layout is specified' , ( ) => {
460462 const navBar = wizardTestFixture . debugElement . query ( By . css ( 'aw-wizard-navigation-bar' ) ) ;
461463
462- expect ( navBar . classes ) . toEqual ( { 'horizontal' : true , 'vertical' : false , 'small' : true ,
463- 'large-filled' : false , 'large-filled-symbols' : false , 'large-empty' : false , 'large-empty-symbols' : false } ) ;
464+ expect ( navBar . classes ) . toEqual ( {
465+ 'horizontal' : true , 'vertical' : false , 'small' : true ,
466+ 'large-filled' : false , 'large-filled-symbols' : false , 'large-empty' : false , 'large-empty-symbols' : false
467+ } ) ;
464468 } ) ;
465469
466470 it ( 'should use the \"small\" layout when it is specified' , ( ) => {
@@ -469,8 +473,10 @@ describe('WizardNavigationBarComponent', () => {
469473 wizardTest . wizard . navBarLayout = 'small' ;
470474 wizardTestFixture . detectChanges ( ) ;
471475
472- expect ( navBar . classes ) . toEqual ( { 'horizontal' : true , 'vertical' : false , 'small' : true ,
473- 'large-filled' : false , 'large-filled-symbols' : false , 'large-empty' : false , 'large-empty-symbols' : false } ) ;
476+ expect ( navBar . classes ) . toEqual ( {
477+ 'horizontal' : true , 'vertical' : false , 'small' : true ,
478+ 'large-filled' : false , 'large-filled-symbols' : false , 'large-empty' : false , 'large-empty-symbols' : false
479+ } ) ;
474480 } ) ;
475481
476482 it ( 'should use the \"large-filled\" layout when it is specified' , ( ) => {
@@ -479,8 +485,10 @@ describe('WizardNavigationBarComponent', () => {
479485 wizardTest . wizard . navBarLayout = 'large-filled' ;
480486 wizardTestFixture . detectChanges ( ) ;
481487
482- expect ( navBar . classes ) . toEqual ( { 'horizontal' : true , 'vertical' : false , 'small' : false ,
483- 'large-filled' : true , 'large-filled-symbols' : false , 'large-empty' : false , 'large-empty-symbols' : false } ) ;
488+ expect ( navBar . classes ) . toEqual ( {
489+ 'horizontal' : true , 'vertical' : false , 'small' : false ,
490+ 'large-filled' : true , 'large-filled-symbols' : false , 'large-empty' : false , 'large-empty-symbols' : false
491+ } ) ;
484492 } ) ;
485493
486494 it ( 'should use the \"large-empty\" layout when it is specified' , ( ) => {
@@ -489,8 +497,10 @@ describe('WizardNavigationBarComponent', () => {
489497 wizardTest . wizard . navBarLayout = 'large-empty' ;
490498 wizardTestFixture . detectChanges ( ) ;
491499
492- expect ( navBar . classes ) . toEqual ( { 'horizontal' : true , 'vertical' : false , 'small' : false ,
493- 'large-filled' : false , 'large-filled-symbols' : false , 'large-empty' : true , 'large-empty-symbols' : false } ) ;
500+ expect ( navBar . classes ) . toEqual ( {
501+ 'horizontal' : true , 'vertical' : false , 'small' : false ,
502+ 'large-filled' : false , 'large-filled-symbols' : false , 'large-empty' : true , 'large-empty-symbols' : false
503+ } ) ;
494504 } ) ;
495505
496506 it ( 'should use the \"large-filled-symbols\" layout when it is specified' , ( ) => {
@@ -499,8 +509,10 @@ describe('WizardNavigationBarComponent', () => {
499509 wizardTest . wizard . navBarLayout = 'large-filled-symbols' ;
500510 wizardTestFixture . detectChanges ( ) ;
501511
502- expect ( navBar . classes ) . toEqual ( { 'horizontal' : true , 'vertical' : false , 'small' : false ,
503- 'large-filled' : false , 'large-filled-symbols' : true , 'large-empty' : false , 'large-empty-symbols' : false } ) ;
512+ expect ( navBar . classes ) . toEqual ( {
513+ 'horizontal' : true , 'vertical' : false , 'small' : false ,
514+ 'large-filled' : false , 'large-filled-symbols' : true , 'large-empty' : false , 'large-empty-symbols' : false
515+ } ) ;
504516 } ) ;
505517
506518 it ( 'should use the \"large-empty-symbols\" layout when it is specified' , ( ) => {
@@ -509,8 +521,10 @@ describe('WizardNavigationBarComponent', () => {
509521 wizardTest . wizard . navBarLayout = 'large-empty-symbols' ;
510522 wizardTestFixture . detectChanges ( ) ;
511523
512- expect ( navBar . classes ) . toEqual ( { 'horizontal' : true , 'vertical' : false , 'small' : false ,
513- 'large-filled' : false , 'large-filled-symbols' : false , 'large-empty' : false , 'large-empty-symbols' : true } ) ;
524+ expect ( navBar . classes ) . toEqual ( {
525+ 'horizontal' : true , 'vertical' : false , 'small' : false ,
526+ 'large-filled' : false , 'large-filled-symbols' : false , 'large-empty' : false , 'large-empty-symbols' : true
527+ } ) ;
514528 } ) ;
515529
516530 it ( 'should show the correct step titles' , ( ) => {
@@ -533,4 +547,25 @@ describe('WizardNavigationBarComponent', () => {
533547 expect ( navigationLinks [ 1 ] . nativeElement . innerText ) . toBe ( 'STEPTITLE 2' ) ;
534548 expect ( navigationLinks [ 2 ] . nativeElement . innerText ) . toBe ( 'STEPTITLE 1' ) ;
535549 } ) ;
550+
551+ it ( 'should have the correct stepId' , ( ) => {
552+ const navigationLiElements = wizardTestFixture . debugElement . queryAll ( By . css ( 'aw-wizard-navigation-bar ul li' ) ) ;
553+
554+ expect ( navigationLiElements . length ) . toBe ( 3 ) ;
555+ expect ( navigationLiElements [ 0 ] . nativeElement . id ) . toBe ( 'step1' ) ;
556+ expect ( navigationLiElements [ 1 ] . nativeElement . id ) . toBe ( '' ) ;
557+ expect ( navigationLiElements [ 2 ] . nativeElement . id ) . toBe ( '' ) ;
558+ } ) ;
559+
560+ it ( 'should change the stepId correctly' , ( ) => {
561+ wizardTest . firstStepId = null ;
562+ wizardTestFixture . detectChanges ( ) ;
563+
564+ const navigationLiElements = wizardTestFixture . debugElement . queryAll ( By . css ( 'aw-wizard-navigation-bar ul li' ) ) ;
565+
566+ expect ( navigationLiElements . length ) . toBe ( 3 ) ;
567+ expect ( navigationLiElements [ 0 ] . nativeElement . id ) . toBe ( '' ) ;
568+ expect ( navigationLiElements [ 1 ] . nativeElement . id ) . toBe ( '' ) ;
569+ expect ( navigationLiElements [ 2 ] . nativeElement . id ) . toBe ( '' ) ;
570+ } ) ;
536571} ) ;
0 commit comments