11import { Component , ViewChild } from '@angular/core' ;
22import { fakeAsync , ComponentFixture , TestBed , waitForAsync , tick } from '@angular/core/testing' ;
33import { configureTestSuite } from '../test-utils/configure-suite' ;
4- import { IgxStepperComponent , IgxStepperModule } from './igx- stepper.component' ;
4+ import { IgxStepperComponent , IgxStepperModule } from './stepper.component' ;
55import { By } from '@angular/platform-browser' ;
66import { UIInteractions } from '../test-utils/ui-interactions.spec' ;
77import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
88import { IgxStepperOrienatation , IgxStepperTitlePosition , IgxStepType , IStepToggledEventArgs , IStepTogglingEventArgs } from './common' ;
99import { pipe , Subject } from 'rxjs' ;
1010import { takeUntil } from 'rxjs/operators' ;
11+ import { IgxIconModule } from 'igniteui-angular' ;
1112
1213const STEPPER_CLASS = 'igx-stepper' ;
1314const STEPPER_HEADER = 'igx-stepper__header' ;
@@ -28,7 +29,8 @@ describe('Rendering Tests', () => {
2829 ] ,
2930 imports : [
3031 NoopAnimationsModule ,
31- IgxStepperModule
32+ IgxStepperModule ,
33+ IgxIconModule
3234 ] ,
3335 providers : [ ]
3436 } ) . compileComponents ( ) ;
@@ -178,7 +180,7 @@ describe('Rendering Tests', () => {
178180 } ) ;
179181
180182 describe ( 'Appearance' , ( ) => {
181- it ( 'should render the stepper according to the specified orientation (vertical/horizontal)' , ( ) => {
183+ it ( 'should render the stepper according to the specified orientation (vertical/horizontal)' , ( ) => {
182184 stepper . orientation = IgxStepperOrienatation . Horizontal ;
183185 fix . detectChanges ( ) ;
184186
@@ -187,7 +189,7 @@ describe('Rendering Tests', () => {
187189 //no css class for vertical
188190 } ) ;
189191
190- it ( 'should indicate the currently active step' , ( ) => {
192+ it ( 'should indicate the currently active step' , ( ) => {
191193 let currentClass = 'igx-stepper__step--current' ;
192194 let step0Header : HTMLElement = stepper . steps [ 0 ] . nativeElement . querySelector ( `.${ STEP_HEADER } ` ) ;
193195 let step1Header : HTMLElement = stepper . steps [ 1 ] . nativeElement . querySelector ( `.${ STEP_HEADER } ` ) ;
@@ -208,7 +210,7 @@ describe('Rendering Tests', () => {
208210 expect ( step1Header ) . toHaveClass ( currentClass ) ;
209211 } ) ;
210212
211- it ( 'should indicate that a step is completed' , ( ) => {
213+ it ( 'should indicate that a step is completed' , ( ) => {
212214 let completedClass = 'igx-stepper__step--completed' ;
213215 stepper . steps [ 0 ] . active = true ;
214216 fix . detectChanges ( ) ;
@@ -232,6 +234,9 @@ describe('Rendering Tests', () => {
232234
233235 stepper . steps [ 0 ] . isValid = false ;
234236 fix . detectChanges ( ) ;
237+
238+ stepper . steps [ 1 ] . active = true ;
239+ fix . detectChanges ( ) ;
235240
236241 expect ( step0Header ) . toHaveClass ( invalidClass ) ;
237242 } ) ;
@@ -287,7 +292,7 @@ describe('Rendering Tests', () => {
287292 }
288293 } ) ;
289294
290- it ( 'should place the title in the step element according to the specified titlePosition when stepType is set to "full"' , ( ) => {
295+ it ( 'should place the title in the step element according to the specified titlePosition when stepType is set to "full"' , ( ) => {
291296 stepper . orientation = IgxStepperOrienatation . Horizontal ;
292297 stepper . stepType = IgxStepType . Full ;
293298 fix . detectChanges ( ) ;
@@ -320,7 +325,7 @@ describe('Rendering Tests', () => {
320325 } ) ;
321326 } ) ;
322327
323- it ( 'should indicate each step with a corresponding number when igxStepIndicator is not specified in the step template and stepType is either "indicator" or "full"' , ( ) => {
328+ it ( 'should indicate each step with a corresponding number when igxStepIndicator is not specified in the step template and stepType is either "indicator" or "full"' , ( ) => {
324329 stepper . stepType = IgxStepType . Full ;
325330 fix . detectChanges ( ) ;
326331
@@ -340,7 +345,38 @@ describe('Rendering Tests', () => {
340345 expect ( indicatorElement4 . textContent ) . toBe ( ( stepper . steps [ 3 ] . index + 1 ) . toString ( ) ) ;
341346 } ) ;
342347
343- it ( 'should allow modifying animationSettings that are used for transitioning between steps ' , ( ) => {
348+ it ( 'Should allow overriding the default invalid and completed indicators' , ( ) => {
349+ let step0Header : HTMLElement = stepper . steps [ 0 ] . nativeElement . querySelector ( `.${ STEP_HEADER } ` ) ;
350+ let invalidClass = 'igx-stepper__step--invalid' ;
351+ let indicatorClass = 'igx-stepper__step-indicator' ;
352+ let indicatorElement = step0Header . querySelector ( `.${ indicatorClass } ` ) . children [ 0 ] ;
353+
354+ expect ( indicatorElement . textContent ) . toBe ( '1' ) ;
355+
356+ stepper . steps [ 0 ] . isValid = false ;
357+ fix . detectChanges ( ) ;
358+
359+ stepper . steps [ 1 ] . active = true ;
360+ fix . detectChanges ( ) ;
361+
362+ indicatorElement = step0Header . querySelector ( `.${ indicatorClass } ` ) . children [ 0 ] ;
363+
364+ expect ( step0Header ) . toHaveClass ( invalidClass ) ;
365+ expect ( indicatorElement . tagName ) . toBe ( 'IGX-ICON' ) ;
366+ expect ( indicatorElement . textContent ) . toBe ( "error" ) ;
367+
368+ stepper . steps [ 0 ] . isValid = true ;
369+ stepper . steps [ 0 ] . completed = true ;
370+ fix . detectChanges ( ) ;
371+
372+ indicatorElement = step0Header . querySelector ( `.${ indicatorClass } ` ) . children [ 0 ] ;
373+
374+ expect ( step0Header ) . not . toHaveClass ( invalidClass ) ;
375+ expect ( indicatorElement . tagName ) . toBe ( 'IGX-ICON' ) ;
376+ expect ( indicatorElement . textContent ) . toBe ( "check" ) ;
377+ } ) ;
378+
379+ it ( 'should allow modifying animationSettings that are used for transitioning between steps ' , ( ) => {
344380 stepper . orientation = IgxStepperOrienatation . Horizontal ;
345381 fix . detectChanges ( ) ;
346382
@@ -382,20 +418,19 @@ describe('Rendering Tests', () => {
382418
383419 expect ( stepper . verticalAnimationType ) . toBe ( fix . componentInstance . verticalAnimationType ) ;
384420 expect ( stepper . verticalAnimationType ) . toBe ( 'none' ) ;
385- } ) ;
386-
421+ } ) ;
387422 } ) ;
388423
389424 describe ( 'Keyboard navigation' , ( ) => {
390- it ( 'should navigate to first/last step on Home/End key press' , fakeAsync ( ( ) => {
425+ it ( 'should navigate to first/last step on Home/End key press' , fakeAsync ( ( ) => {
391426 stepper . steps [ 3 ] . nativeElement . focus ( ) ;
392427 fix . detectChanges ( ) ;
393428
394429 expect ( document . activeElement ) . toBe ( stepper . steps [ 3 ] . nativeElement as Element ) ;
395430
396431 UIInteractions . triggerKeyDownEvtUponElem ( 'home' , stepper . steps [ 3 ] . nativeElement ) ;
397432 fix . detectChanges ( ) ;
398-
433+
399434 expect ( stepper . steps [ 0 ] . nativeElement as Element ) . toBe ( document . activeElement ) ;
400435
401436 UIInteractions . triggerKeyDownEvtUponElem ( 'end' , stepper . steps [ 0 ] . nativeElement ) ;
@@ -404,7 +439,7 @@ describe('Rendering Tests', () => {
404439 expect ( stepper . steps [ 4 ] . nativeElement as Element ) . toBe ( document . activeElement ) ;
405440 } ) ) ;
406441
407- it ( 'should activate the currently focused step on Enter/Space key press' , fakeAsync ( ( ) => {
442+ it ( 'should activate the currently focused step on Enter/Space key press' , fakeAsync ( ( ) => {
408443 stepper . steps [ 0 ] . active = true ;
409444 fix . detectChanges ( ) ;
410445
@@ -433,7 +468,7 @@ describe('Rendering Tests', () => {
433468 expect ( stepper . steps [ 4 ] . active ) . toBeTruthy ( ) ;
434469 } ) ) ;
435470
436- it ( 'should navigate to the next/previous step in horizontal orientation on Arrow Right/Left key press' , fakeAsync ( ( ) => {
471+ it ( 'should navigate to the next/previous step in horizontal orientation on Arrow Right/Left key press' , fakeAsync ( ( ) => {
437472 stepper . steps [ 0 ] . active = true ;
438473 fix . detectChanges ( ) ;
439474
@@ -456,7 +491,7 @@ describe('Rendering Tests', () => {
456491 expect ( stepper . steps [ 0 ] . nativeElement as Element ) . toBe ( document . activeElement ) ;
457492 } ) ) ;
458493
459- it ( 'should navigate to the next/previous step in vertical orientation on Arrow Down/Up key press' , fakeAsync ( ( ) => {
494+ it ( 'should navigate to the next/previous step in vertical orientation on Arrow Down/Up key press' , fakeAsync ( ( ) => {
460495 stepper . orientation = IgxStepperOrienatation . Vertical ;
461496 stepper . steps [ 0 ] . active = true ;
462497 fix . detectChanges ( ) ;
@@ -480,7 +515,7 @@ describe('Rendering Tests', () => {
480515 expect ( stepper . steps [ 0 ] . nativeElement as Element ) . toBe ( document . activeElement ) ;
481516 } ) ) ;
482517
483- it ( 'should specify tabIndex="0" for the active step and tabIndex="-1" for the other steps' , fakeAsync ( ( ) => {
518+ it ( 'should specify tabIndex="0" for the active step and tabIndex="-1" for the other steps' , fakeAsync ( ( ) => {
484519 let stepContent = stepper . nativeElement . querySelector ( `.${ STEP_CONTENT } ` ) ;
485520
486521 expect ( stepper . steps [ 0 ] . tabIndex ) . toBe ( 0 ) ;
@@ -515,8 +550,17 @@ describe('Rendering Tests', () => {
515550 template : `
516551 <igx-stepper #stepper [orientation]="'Horizontal'" [verticalAnimationType]="verticalAnimationType"
517552 [horizontalAnimationType]="horizontalAnimationType" [animationDuration]="animationDuration">
553+
554+ <ng-template igxStepInvalidIndicator>
555+ <igx-icon>error</igx-icon>
556+ </ng-template>
557+
558+ <ng-template igxStepCompletedIndicator>
559+ <igx-icon>check</igx-icon>
560+ </ng-template>
561+
518562 <igx-step #step1 [active]="true">
519- <span igxStepIcon >1</span>
563+ <span igxStepIndicator >1</span>
520564 <span igxStepTitle>Step No 1</span>
521565 <span igxStepSubTitle>Step SubTitle</span>
522566 <div igxStepContent class="sample-body">
@@ -525,7 +569,7 @@ describe('Rendering Tests', () => {
525569 </igx-step>
526570
527571 <igx-step #step2>
528- <span igxStepIcon >2</span>
572+ <span igxStepIndicator >2</span>
529573 <span igxStepTitle>Step No 2</span>
530574 <span igxStepSubTitle>Step SubTitle</span>
531575 <div igxStepContent class="sample-body">
@@ -534,7 +578,7 @@ describe('Rendering Tests', () => {
534578 </igx-step>
535579
536580 <igx-step #step3>
537- <span igxStepIcon >3</span>
581+ <span igxStepIndicator >3</span>
538582 <span igxStepTitle>Step No 3</span>
539583 <span igxStepSubTitle>Step SubTitle</span>
540584 <div igxStepContent class="sample-body">
@@ -543,15 +587,15 @@ describe('Rendering Tests', () => {
543587 </igx-step>
544588
545589 <igx-step #step4>
546- <span igxStepTitle >Step No 4</span>
590+ <span igxStepIndicator >Step No 4</span>
547591 <span igxStepSubTitle>Step SubTitle</span>
548592 <div igxStepContent class="sample-body">
549593 <p>Test step 4</p>
550594 </div>
551595 </igx-step>
552596
553597 <igx-step #step5 >
554- <span igxStepIcon >5</span>
598+ <span igxStepIndicator >5</span>
555599 <span igxStepTitle>Step No 5</span>
556600 <span igxStepSubTitle>Step SubTitle</span>
557601 <div igxStepContent class="sample-body">
0 commit comments