1
1
import { Component , ViewChild } from '@angular/core' ;
2
2
import { fakeAsync , ComponentFixture , TestBed , waitForAsync , tick } from '@angular/core/testing' ;
3
3
import { configureTestSuite } from '../test-utils/configure-suite' ;
4
- import { IgxStepperComponent , IgxStepperModule } from './igx- stepper.component' ;
4
+ import { IgxStepperComponent , IgxStepperModule } from './stepper.component' ;
5
5
import { By } from '@angular/platform-browser' ;
6
6
import { UIInteractions } from '../test-utils/ui-interactions.spec' ;
7
7
import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
8
8
import { IgxStepperOrienatation , IgxStepperTitlePosition , IgxStepType , IStepToggledEventArgs , IStepTogglingEventArgs } from './common' ;
9
9
import { pipe , Subject } from 'rxjs' ;
10
10
import { takeUntil } from 'rxjs/operators' ;
11
+ import { IgxIconModule } from 'igniteui-angular' ;
11
12
12
13
const STEPPER_CLASS = 'igx-stepper' ;
13
14
const STEPPER_HEADER = 'igx-stepper__header' ;
@@ -28,7 +29,8 @@ describe('Rendering Tests', () => {
28
29
] ,
29
30
imports : [
30
31
NoopAnimationsModule ,
31
- IgxStepperModule
32
+ IgxStepperModule ,
33
+ IgxIconModule
32
34
] ,
33
35
providers : [ ]
34
36
} ) . compileComponents ( ) ;
@@ -178,7 +180,7 @@ describe('Rendering Tests', () => {
178
180
} ) ;
179
181
180
182
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)' , ( ) => {
182
184
stepper . orientation = IgxStepperOrienatation . Horizontal ;
183
185
fix . detectChanges ( ) ;
184
186
@@ -187,7 +189,7 @@ describe('Rendering Tests', () => {
187
189
//no css class for vertical
188
190
} ) ;
189
191
190
- it ( 'should indicate the currently active step' , ( ) => {
192
+ it ( 'should indicate the currently active step' , ( ) => {
191
193
let currentClass = 'igx-stepper__step--current' ;
192
194
let step0Header : HTMLElement = stepper . steps [ 0 ] . nativeElement . querySelector ( `.${ STEP_HEADER } ` ) ;
193
195
let step1Header : HTMLElement = stepper . steps [ 1 ] . nativeElement . querySelector ( `.${ STEP_HEADER } ` ) ;
@@ -208,7 +210,7 @@ describe('Rendering Tests', () => {
208
210
expect ( step1Header ) . toHaveClass ( currentClass ) ;
209
211
} ) ;
210
212
211
- it ( 'should indicate that a step is completed' , ( ) => {
213
+ it ( 'should indicate that a step is completed' , ( ) => {
212
214
let completedClass = 'igx-stepper__step--completed' ;
213
215
stepper . steps [ 0 ] . active = true ;
214
216
fix . detectChanges ( ) ;
@@ -232,6 +234,9 @@ describe('Rendering Tests', () => {
232
234
233
235
stepper . steps [ 0 ] . isValid = false ;
234
236
fix . detectChanges ( ) ;
237
+
238
+ stepper . steps [ 1 ] . active = true ;
239
+ fix . detectChanges ( ) ;
235
240
236
241
expect ( step0Header ) . toHaveClass ( invalidClass ) ;
237
242
} ) ;
@@ -287,7 +292,7 @@ describe('Rendering Tests', () => {
287
292
}
288
293
} ) ;
289
294
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"' , ( ) => {
291
296
stepper . orientation = IgxStepperOrienatation . Horizontal ;
292
297
stepper . stepType = IgxStepType . Full ;
293
298
fix . detectChanges ( ) ;
@@ -320,7 +325,7 @@ describe('Rendering Tests', () => {
320
325
} ) ;
321
326
} ) ;
322
327
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"' , ( ) => {
324
329
stepper . stepType = IgxStepType . Full ;
325
330
fix . detectChanges ( ) ;
326
331
@@ -340,7 +345,38 @@ describe('Rendering Tests', () => {
340
345
expect ( indicatorElement4 . textContent ) . toBe ( ( stepper . steps [ 3 ] . index + 1 ) . toString ( ) ) ;
341
346
} ) ;
342
347
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 ' , ( ) => {
344
380
stepper . orientation = IgxStepperOrienatation . Horizontal ;
345
381
fix . detectChanges ( ) ;
346
382
@@ -382,20 +418,19 @@ describe('Rendering Tests', () => {
382
418
383
419
expect ( stepper . verticalAnimationType ) . toBe ( fix . componentInstance . verticalAnimationType ) ;
384
420
expect ( stepper . verticalAnimationType ) . toBe ( 'none' ) ;
385
- } ) ;
386
-
421
+ } ) ;
387
422
} ) ;
388
423
389
424
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 ( ( ) => {
391
426
stepper . steps [ 3 ] . nativeElement . focus ( ) ;
392
427
fix . detectChanges ( ) ;
393
428
394
429
expect ( document . activeElement ) . toBe ( stepper . steps [ 3 ] . nativeElement as Element ) ;
395
430
396
431
UIInteractions . triggerKeyDownEvtUponElem ( 'home' , stepper . steps [ 3 ] . nativeElement ) ;
397
432
fix . detectChanges ( ) ;
398
-
433
+
399
434
expect ( stepper . steps [ 0 ] . nativeElement as Element ) . toBe ( document . activeElement ) ;
400
435
401
436
UIInteractions . triggerKeyDownEvtUponElem ( 'end' , stepper . steps [ 0 ] . nativeElement ) ;
@@ -404,7 +439,7 @@ describe('Rendering Tests', () => {
404
439
expect ( stepper . steps [ 4 ] . nativeElement as Element ) . toBe ( document . activeElement ) ;
405
440
} ) ) ;
406
441
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 ( ( ) => {
408
443
stepper . steps [ 0 ] . active = true ;
409
444
fix . detectChanges ( ) ;
410
445
@@ -433,7 +468,7 @@ describe('Rendering Tests', () => {
433
468
expect ( stepper . steps [ 4 ] . active ) . toBeTruthy ( ) ;
434
469
} ) ) ;
435
470
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 ( ( ) => {
437
472
stepper . steps [ 0 ] . active = true ;
438
473
fix . detectChanges ( ) ;
439
474
@@ -456,7 +491,7 @@ describe('Rendering Tests', () => {
456
491
expect ( stepper . steps [ 0 ] . nativeElement as Element ) . toBe ( document . activeElement ) ;
457
492
} ) ) ;
458
493
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 ( ( ) => {
460
495
stepper . orientation = IgxStepperOrienatation . Vertical ;
461
496
stepper . steps [ 0 ] . active = true ;
462
497
fix . detectChanges ( ) ;
@@ -480,7 +515,7 @@ describe('Rendering Tests', () => {
480
515
expect ( stepper . steps [ 0 ] . nativeElement as Element ) . toBe ( document . activeElement ) ;
481
516
} ) ) ;
482
517
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 ( ( ) => {
484
519
let stepContent = stepper . nativeElement . querySelector ( `.${ STEP_CONTENT } ` ) ;
485
520
486
521
expect ( stepper . steps [ 0 ] . tabIndex ) . toBe ( 0 ) ;
@@ -515,8 +550,17 @@ describe('Rendering Tests', () => {
515
550
template : `
516
551
<igx-stepper #stepper [orientation]="'Horizontal'" [verticalAnimationType]="verticalAnimationType"
517
552
[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
+
518
562
<igx-step #step1 [active]="true">
519
- <span igxStepIcon >1</span>
563
+ <span igxStepIndicator >1</span>
520
564
<span igxStepTitle>Step No 1</span>
521
565
<span igxStepSubTitle>Step SubTitle</span>
522
566
<div igxStepContent class="sample-body">
@@ -525,7 +569,7 @@ describe('Rendering Tests', () => {
525
569
</igx-step>
526
570
527
571
<igx-step #step2>
528
- <span igxStepIcon >2</span>
572
+ <span igxStepIndicator >2</span>
529
573
<span igxStepTitle>Step No 2</span>
530
574
<span igxStepSubTitle>Step SubTitle</span>
531
575
<div igxStepContent class="sample-body">
@@ -534,7 +578,7 @@ describe('Rendering Tests', () => {
534
578
</igx-step>
535
579
536
580
<igx-step #step3>
537
- <span igxStepIcon >3</span>
581
+ <span igxStepIndicator >3</span>
538
582
<span igxStepTitle>Step No 3</span>
539
583
<span igxStepSubTitle>Step SubTitle</span>
540
584
<div igxStepContent class="sample-body">
@@ -543,15 +587,15 @@ describe('Rendering Tests', () => {
543
587
</igx-step>
544
588
545
589
<igx-step #step4>
546
- <span igxStepTitle >Step No 4</span>
590
+ <span igxStepIndicator >Step No 4</span>
547
591
<span igxStepSubTitle>Step SubTitle</span>
548
592
<div igxStepContent class="sample-body">
549
593
<p>Test step 4</p>
550
594
</div>
551
595
</igx-step>
552
596
553
597
<igx-step #step5 >
554
- <span igxStepIcon >5</span>
598
+ <span igxStepIndicator >5</span>
555
599
<span igxStepTitle>Step No 5</span>
556
600
<span igxStepSubTitle>Step SubTitle</span>
557
601
<div igxStepContent class="sample-body">
0 commit comments