@@ -6,15 +6,14 @@ 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
- import { pipe , Subject } from 'rxjs' ;
9
+ import { Subject } from 'rxjs' ;
10
10
import { takeUntil } from 'rxjs/operators' ;
11
11
import { IgxIconModule } from 'igniteui-angular' ;
12
12
13
13
const STEPPER_CLASS = 'igx-stepper' ;
14
14
const STEPPER_HEADER = 'igx-stepper__header' ;
15
15
const STEP_TAG = 'IGX-STEP' ;
16
16
const STEP_HEADER = 'igx-stepper__step-header' ;
17
- const STEP_CONTENT = 'igx-stepper__step-content' ;
18
17
19
18
describe ( 'Rendering Tests' , ( ) => {
20
19
configureTestSuite ( ) ;
@@ -98,13 +97,13 @@ describe('Rendering Tests', () => {
98
97
expect ( changedSpy ) . not . toHaveBeenCalled ( ) ;
99
98
100
99
let argsIng : IStepTogglingEventArgs = {
101
- activeStep : stepper . steps [ 1 ] ,
102
- previousActiveStep : stepper . steps [ 0 ] ,
100
+ newIndex : stepper . steps [ 1 ] . index ,
101
+ oldIndex : stepper . steps [ 0 ] . index ,
103
102
owner : stepper ,
104
103
cancel : false
105
104
} ;
106
105
let argsEd : IStepToggledEventArgs = {
107
- activeStep : stepper . steps [ 1 ] ,
106
+ index : stepper . steps [ 1 ] . index ,
108
107
owner : stepper ,
109
108
} ;
110
109
@@ -125,8 +124,8 @@ describe('Rendering Tests', () => {
125
124
expect ( changingSpy ) . not . toHaveBeenCalled ( ) ;
126
125
127
126
let argsIng : IStepTogglingEventArgs = {
128
- activeStep : stepper . steps [ 1 ] ,
129
- previousActiveStep : stepper . steps [ 0 ] ,
127
+ newIndex : stepper . steps [ 1 ] . index ,
128
+ oldIndex : stepper . steps [ 0 ] . index ,
130
129
owner : stepper ,
131
130
cancel : true
132
131
} ;
@@ -185,7 +184,6 @@ describe('Rendering Tests', () => {
185
184
fix . detectChanges ( ) ;
186
185
187
186
expect ( stepper . nativeElement ) . toHaveClass ( 'igx-stepper--horizontal' ) ;
188
-
189
187
//no css class for vertical
190
188
} ) ;
191
189
@@ -224,7 +222,7 @@ describe('Rendering Tests', () => {
224
222
expect ( stepper . steps [ 0 ] . nativeElement ) . toHaveClass ( completedClass ) ;
225
223
} ) ;
226
224
227
- it ( 'should indicate that a step is invalid' , ( ) => {
225
+ it ( 'should indicate that a step is invalid' , ( ) => {
228
226
let step0Header : HTMLElement = stepper . steps [ 0 ] . nativeElement . querySelector ( `.${ STEP_HEADER } ` ) ;
229
227
let invalidClass = 'igx-stepper__step--invalid' ;
230
228
stepper . steps [ 0 ] . isValid = true ;
@@ -235,6 +233,8 @@ describe('Rendering Tests', () => {
235
233
stepper . steps [ 0 ] . isValid = false ;
236
234
fix . detectChanges ( ) ;
237
235
236
+ expect ( step0Header ) . not . toHaveClass ( invalidClass ) ;
237
+
238
238
stepper . steps [ 1 ] . active = true ;
239
239
fix . detectChanges ( ) ;
240
240
@@ -253,9 +253,14 @@ describe('Rendering Tests', () => {
253
253
let indicatorElement = stepper . steps [ i ] . nativeElement . querySelector ( `div.${ stepIndicatorClass } ` ) ;
254
254
let titleElement = stepper . steps [ i ] . nativeElement . querySelector ( `.${ stepTitleClass } ` ) ;
255
255
let subtitleElement = stepper . steps [ i ] . nativeElement . querySelector ( `.${ stepSubitleClass } ` ) ;
256
-
256
+
257
257
expect ( indicatorElement ) . not . toBeNull ( ) ;
258
258
expect ( stepper . steps [ i ] . isIndicatorVisible ) . toBeTruthy ( ) ;
259
+ if ( i === 3 ) {
260
+ expect ( titleElement ) . toBeNull ( ) ;
261
+ expect ( subtitleElement ) . toBeNull ( ) ;
262
+ continue ;
263
+ }
259
264
expect ( titleElement ) . not . toBeNull ( ) ;
260
265
expect ( subtitleElement ) . not . toBeNull ( ) ;
261
266
expect ( stepper . steps [ i ] . isTitleVisible ) . toBeTruthy ( ) ;
@@ -283,9 +288,14 @@ describe('Rendering Tests', () => {
283
288
let indicatorElement = stepper . steps [ i ] . nativeElement . querySelector ( `div.${ stepIndicatorClass } ` ) ;
284
289
let titleElement = stepper . steps [ i ] . nativeElement . querySelector ( `.${ stepTitleClass } ` ) ;
285
290
let subtitleElement = stepper . steps [ i ] . nativeElement . querySelector ( `.${ stepSubitleClass } ` ) ;
286
-
291
+
287
292
expect ( indicatorElement ) . toBeNull ( ) ;
288
293
expect ( stepper . steps [ i ] . isIndicatorVisible ) . toBeFalsy ( ) ;
294
+ if ( i === 3 ) {
295
+ expect ( titleElement ) . toBeNull ( ) ;
296
+ expect ( subtitleElement ) . toBeNull ( ) ;
297
+ continue ;
298
+ }
289
299
expect ( titleElement ) . not . toBeNull ( ) ;
290
300
expect ( subtitleElement ) . not . toBeNull ( ) ;
291
301
expect ( stepper . steps [ i ] . isTitleVisible ) . toBeTruthy ( ) ;
@@ -330,28 +340,34 @@ describe('Rendering Tests', () => {
330
340
fix . detectChanges ( ) ;
331
341
332
342
let stepIndicatorClass = "igx-stepper__step-indicator" ;
333
- let indicatorElement4 = stepper . steps [ 3 ] . nativeElement . querySelector ( `div.${ stepIndicatorClass } ` ) ;
343
+ let indicatorElement5 = stepper . steps [ 4 ] . nativeElement . querySelector ( `div.${ stepIndicatorClass } ` ) ;
334
344
335
- expect ( stepper . steps [ 3 ] . isIndicatorVisible ) . toBeTruthy ( ) ;
336
- expect ( indicatorElement4 ) . not . toBeNull ( ) ;
337
- expect ( indicatorElement4 . textContent ) . toBe ( ( stepper . steps [ 3 ] . index + 1 ) . toString ( ) ) ;
345
+ expect ( stepper . steps [ 4 ] . isIndicatorVisible ) . toBeTruthy ( ) ;
346
+ expect ( indicatorElement5 ) . not . toBeNull ( ) ;
347
+ expect ( indicatorElement5 . textContent ) . toBe ( ( stepper . steps [ 4 ] . index + 1 ) . toString ( ) ) ;
338
348
339
349
stepper . stepType = IgxStepType . Indicator ;
340
350
fix . detectChanges ( ) ;
341
351
342
- indicatorElement4 = stepper . steps [ 3 ] . nativeElement . querySelector ( `div.${ stepIndicatorClass } ` ) ;
352
+ indicatorElement5 = stepper . steps [ 4 ] . nativeElement . querySelector ( `div.${ stepIndicatorClass } ` ) ;
343
353
344
- expect ( indicatorElement4 ) . not . toBeNull ( ) ;
345
- expect ( indicatorElement4 . textContent ) . toBe ( ( stepper . steps [ 3 ] . index + 1 ) . toString ( ) ) ;
354
+ expect ( indicatorElement5 ) . not . toBeNull ( ) ;
355
+ expect ( indicatorElement5 . textContent ) . toBe ( ( stepper . steps [ 4 ] . index + 1 ) . toString ( ) ) ;
346
356
} ) ;
347
357
348
- it ( 'Should allow overriding the default invalid and completed indicators' , ( ) => {
358
+ it ( 'should allow overriding the default invalid, completed and active indicators' , ( ) => {
349
359
let step0Header : HTMLElement = stepper . steps [ 0 ] . nativeElement . querySelector ( `.${ STEP_HEADER } ` ) ;
350
- let invalidClass = 'igx-stepper__step--invalid' ;
351
360
let indicatorClass = 'igx-stepper__step-indicator' ;
361
+ let invalidClass = 'igx-stepper__step--invalid' ;
362
+ let completedClass = 'igx-stepper__step--completed' ;
363
+ let currentClass = 'igx-stepper__step--current' ;
352
364
let indicatorElement = step0Header . querySelector ( `.${ indicatorClass } ` ) . children [ 0 ] ;
353
365
354
- expect ( indicatorElement . textContent ) . toBe ( '1' ) ;
366
+ expect ( step0Header ) . not . toHaveClass ( invalidClass ) ;
367
+ expect ( step0Header ) . toHaveClass ( currentClass ) ;
368
+ expect ( stepper . steps [ 0 ] . nativeElement ) . not . toHaveClass ( completedClass ) ;
369
+ expect ( indicatorElement . tagName ) . toBe ( 'IGX-ICON' ) ;
370
+ expect ( indicatorElement . textContent ) . toBe ( "edit" ) ;
355
371
356
372
stepper . steps [ 0 ] . isValid = false ;
357
373
fix . detectChanges ( ) ;
@@ -362,6 +378,8 @@ describe('Rendering Tests', () => {
362
378
indicatorElement = step0Header . querySelector ( `.${ indicatorClass } ` ) . children [ 0 ] ;
363
379
364
380
expect ( step0Header ) . toHaveClass ( invalidClass ) ;
381
+ expect ( step0Header ) . not . toHaveClass ( currentClass ) ;
382
+ expect ( stepper . steps [ 0 ] . nativeElement ) . not . toHaveClass ( completedClass ) ;
365
383
expect ( indicatorElement . tagName ) . toBe ( 'IGX-ICON' ) ;
366
384
expect ( indicatorElement . textContent ) . toBe ( "error" ) ;
367
385
@@ -372,10 +390,23 @@ describe('Rendering Tests', () => {
372
390
indicatorElement = step0Header . querySelector ( `.${ indicatorClass } ` ) . children [ 0 ] ;
373
391
374
392
expect ( step0Header ) . not . toHaveClass ( invalidClass ) ;
393
+ expect ( step0Header ) . not . toHaveClass ( currentClass ) ;
394
+ expect ( stepper . steps [ 0 ] . nativeElement ) . toHaveClass ( completedClass ) ;
375
395
expect ( indicatorElement . tagName ) . toBe ( 'IGX-ICON' ) ;
376
396
expect ( indicatorElement . textContent ) . toBe ( "check" ) ;
377
397
} ) ;
378
398
399
+ it ( 'should be able to display the steps\' content above the steps headers when the stepper is horizontally orientated' , ( ) => {
400
+ stepper . orientation = IgxStepperOrienatation . Horizontal ;
401
+ let contentTopClass = "igx-stepper--content-top" ;
402
+ expect ( stepper . nativeElement ) . not . toHaveClass ( contentTopClass ) ;
403
+
404
+ stepper . contentTop = true ;
405
+ fix . detectChanges ( ) ;
406
+
407
+ expect ( stepper . nativeElement ) . toHaveClass ( contentTopClass ) ;
408
+ } ) ;
409
+
379
410
it ( 'should allow modifying animationSettings that are used for transitioning between steps ' , ( ) => {
380
411
stepper . orientation = IgxStepperOrienatation . Horizontal ;
381
412
fix . detectChanges ( ) ;
@@ -516,7 +547,12 @@ describe('Rendering Tests', () => {
516
547
} ) ) ;
517
548
518
549
it ( 'should specify tabIndex="0" for the active step and tabIndex="-1" for the other steps' , fakeAsync ( ( ) => {
519
- let stepContent = stepper . nativeElement . querySelector ( `.${ STEP_CONTENT } ` ) ;
550
+ stepper . orientation = IgxStepperOrienatation . Horizontal ;
551
+ stepper . steps [ 0 ] . active = true ;
552
+ fix . detectChanges ( ) ;
553
+
554
+ stepper . steps [ 0 ] . nativeElement . focus ( ) ;
555
+ let stepContent = stepper . nativeElement . querySelector ( `#${ stepper . steps [ 0 ] . id . replace ( 'step' , 'content' ) } ` ) ;
520
556
521
557
expect ( stepper . steps [ 0 ] . tabIndex ) . toBe ( 0 ) ;
522
558
expect ( stepContent . getAttribute ( "tabIndex" ) ) . toBe ( "0" ) ;
@@ -535,13 +571,31 @@ describe('Rendering Tests', () => {
535
571
UIInteractions . triggerKeyDownEvtUponElem ( 'Enter' , stepper . steps [ 1 ] . nativeElement ) ;
536
572
fix . detectChanges ( ) ;
537
573
538
- stepContent = stepper . nativeElement . querySelector ( `.${ STEP_CONTENT } ` ) ;
574
+ stepContent = stepper . nativeElement . querySelector ( `#${ stepper . steps [ 1 ] . id . replace ( 'step' , 'content' ) } ` ) ;
575
+ expect ( stepContent ) . not . toBeNull ( ) ;
539
576
expect ( stepContent . getAttribute ( "tabIndex" ) ) . toBe ( "0" ) ;
540
577
541
578
for ( let i = 0 ; i < stepper . steps . length ; i ++ ) {
542
579
if ( i === 1 ) continue ;
543
580
expect ( stepper . steps [ i ] . tabIndex ) . toBe ( - 1 ) ;
544
581
}
582
+
583
+ stepper . orientation = IgxStepperOrienatation . Vertical ;
584
+ stepper . steps [ 0 ] . active = true ;
585
+ fix . detectChanges ( ) ;
586
+
587
+ stepContent = stepper . nativeElement . querySelector ( `#${ stepper . steps [ 0 ] . id . replace ( 'step' , 'content' ) } ` ) ;
588
+ stepper . steps [ 0 ] . nativeElement . focus ( ) ;
589
+
590
+ expect ( stepper . steps [ 0 ] . tabIndex ) . toBe ( 0 ) ;
591
+ expect ( stepContent ) . not . toBeNull ( ) ;
592
+ expect ( stepContent . getAttribute ( "tabIndex" ) ) . toBe ( "0" ) ;
593
+
594
+ for ( let i = 1 ; i < stepper . steps . length ; i ++ ) {
595
+ stepContent = stepper . nativeElement . querySelector ( `#${ stepper . steps [ i ] . id . replace ( 'step' , 'content' ) } ` ) ;
596
+ expect ( stepper . steps [ i ] . tabIndex ) . toBe ( - 1 ) ;
597
+ expect ( stepContent ) . toBeNull ( ) ;
598
+ }
545
599
} ) ) ;
546
600
} ) ;
547
601
} ) ;
@@ -559,6 +613,10 @@ describe('Rendering Tests', () => {
559
613
<igx-icon>check</igx-icon>
560
614
</ng-template>
561
615
616
+ <ng-template igxStepActiveIndicator>
617
+ <igx-icon>edit</igx-icon>
618
+ </ng-template>
619
+
562
620
<igx-step #step1 [active]="true">
563
621
<span igxStepIndicator>1</span>
564
622
<span igxStepTitle>Step No 1</span>
@@ -587,15 +645,16 @@ describe('Rendering Tests', () => {
587
645
</igx-step>
588
646
589
647
<igx-step #step4>
590
- <span igxStepIndicator>Step No 4</span>
591
- <span igxStepSubTitle>Step SubTitle</span>
648
+ <span igxStepIndicator>4</span>
649
+ <!-- <span igxStepTitle>Step No 4</span> -->
650
+ <!-- <span igxStepSubTitle>Step SubTitle</span> -->
592
651
<div igxStepContent class="sample-body">
593
652
<p>Test step 4</p>
594
653
</div>
595
654
</igx-step>
596
655
597
656
<igx-step #step5 >
598
- <span igxStepIndicator>5</span>
657
+ <!-- < span igxStepIndicator>5</span> -- >
599
658
<span igxStepTitle>Step No 5</span>
600
659
<span igxStepSubTitle>Step SubTitle</span>
601
660
<div igxStepContent class="sample-body">
0 commit comments