@@ -75,8 +75,9 @@ describe('MatStepper', () => {
75
75
} ) ;
76
76
77
77
it ( 'should default to the first step' , ( ) => {
78
- let stepperComponent = fixture . debugElement
78
+ const stepperComponent : MatStepper = fixture . debugElement
79
79
. query ( By . css ( 'mat-stepper' ) ) ! . componentInstance ;
80
+
80
81
expect ( stepperComponent . selectedIndex ) . toBe ( 0 ) ;
81
82
} ) ;
82
83
@@ -101,8 +102,9 @@ describe('MatStepper', () => {
101
102
} ) ;
102
103
103
104
it ( 'should change selected index on header click' , ( ) => {
104
- let stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) ;
105
- let stepperComponent =
105
+ const stepHeaders =
106
+ fixture . debugElement . queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) ;
107
+ const stepperComponent =
106
108
fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
107
109
108
110
expect ( stepperComponent . selectedIndex ) . toBe ( 0 ) ;
@@ -126,27 +128,27 @@ describe('MatStepper', () => {
126
128
} ) ;
127
129
128
130
it ( 'should set the "tablist" role on stepper' , ( ) => {
129
- let stepperEl = fixture . debugElement . query ( By . css ( 'mat-stepper' ) ) ! . nativeElement ;
131
+ const stepperEl = fixture . debugElement . query ( By . css ( 'mat-stepper' ) ) ! . nativeElement ;
130
132
expect ( stepperEl . getAttribute ( 'role' ) ) . toBe ( 'tablist' ) ;
131
133
} ) ;
132
134
133
135
it ( 'should set aria-expanded of content correctly' , ( ) => {
134
- let stepContents = fixture . debugElement . queryAll ( By . css ( `.mat-vertical-stepper-content` ) ) ;
135
- let stepperComponent =
136
+ const stepContents = fixture . debugElement . queryAll ( By . css ( `.mat-vertical-stepper-content` ) ) ;
137
+ const stepperComponent =
136
138
fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
137
- let firstStepContentEl = stepContents [ 0 ] . nativeElement ;
139
+ const firstStepContentEl = stepContents [ 0 ] . nativeElement ;
138
140
expect ( firstStepContentEl . getAttribute ( 'aria-expanded' ) ) . toBe ( 'true' ) ;
139
141
140
142
stepperComponent . selectedIndex = 1 ;
141
143
fixture . detectChanges ( ) ;
142
144
143
145
expect ( firstStepContentEl . getAttribute ( 'aria-expanded' ) ) . toBe ( 'false' ) ;
144
- let secondStepContentEl = stepContents [ 1 ] . nativeElement ;
146
+ const secondStepContentEl = stepContents [ 1 ] . nativeElement ;
145
147
expect ( secondStepContentEl . getAttribute ( 'aria-expanded' ) ) . toBe ( 'true' ) ;
146
148
} ) ;
147
149
148
150
it ( 'should display the correct label' , ( ) => {
149
- let stepperComponent =
151
+ const stepperComponent =
150
152
fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
151
153
let selectedLabel = fixture . nativeElement . querySelector ( '[aria-selected="true"]' ) ;
152
154
expect ( selectedLabel . textContent ) . toMatch ( 'Step 1' ) ;
@@ -165,7 +167,7 @@ describe('MatStepper', () => {
165
167
} ) ;
166
168
167
169
it ( 'should go to next available step when the next button is clicked' , ( ) => {
168
- let stepperComponent =
170
+ const stepperComponent =
169
171
fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
170
172
171
173
expect ( stepperComponent . selectedIndex ) . toBe ( 0 ) ;
@@ -198,7 +200,7 @@ describe('MatStepper', () => {
198
200
} ) ;
199
201
200
202
it ( 'should go to previous available step when the previous button is clicked' , ( ) => {
201
- let stepperComponent =
203
+ const stepperComponent =
202
204
fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
203
205
204
206
expect ( stepperComponent . selectedIndex ) . toBe ( 0 ) ;
@@ -232,7 +234,7 @@ describe('MatStepper', () => {
232
234
} ) ;
233
235
234
236
it ( 'should set the correct step position for animation' , ( ) => {
235
- let stepperComponent =
237
+ const stepperComponent =
236
238
fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
237
239
238
240
expect ( stepperComponent . _getAnimationDirection ( 0 ) ) . toBe ( 'current' ) ;
@@ -255,10 +257,11 @@ describe('MatStepper', () => {
255
257
} ) ;
256
258
257
259
it ( 'should not set focus on header of selected step if header is not clicked' , ( ) => {
258
- let stepperComponent =
260
+ const stepperComponent =
259
261
fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
260
- let stepHeaderEl = fixture . debugElement . queryAll ( By . css ( 'mat-step-header' ) ) [ 1 ] . nativeElement ;
261
- let nextButtonNativeEl = fixture . debugElement
262
+ const stepHeaderEl =
263
+ fixture . debugElement . queryAll ( By . css ( 'mat-step-header' ) ) [ 1 ] . nativeElement ;
264
+ const nextButtonNativeEl = fixture . debugElement
262
265
. queryAll ( By . directive ( MatStepperNext ) ) [ 0 ] . nativeElement ;
263
266
spyOn ( stepHeaderEl , 'focus' ) ;
264
267
nextButtonNativeEl . click ( ) ;
@@ -269,10 +272,11 @@ describe('MatStepper', () => {
269
272
} ) ;
270
273
271
274
it ( 'should focus next step header if focus is inside the stepper' , ( ) => {
272
- let stepperComponent =
275
+ const stepperComponent =
273
276
fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
274
- let stepHeaderEl = fixture . debugElement . queryAll ( By . css ( 'mat-step-header' ) ) [ 1 ] . nativeElement ;
275
- let nextButtonNativeEl = fixture . debugElement
277
+ const stepHeaderEl =
278
+ fixture . debugElement . queryAll ( By . css ( 'mat-step-header' ) ) [ 1 ] . nativeElement ;
279
+ const nextButtonNativeEl = fixture . debugElement
276
280
. queryAll ( By . directive ( MatStepperNext ) ) [ 0 ] . nativeElement ;
277
281
spyOn ( stepHeaderEl , 'focus' ) ;
278
282
nextButtonNativeEl . focus ( ) ;
@@ -284,12 +288,12 @@ describe('MatStepper', () => {
284
288
} ) ;
285
289
286
290
it ( 'should only be able to return to a previous step if it is editable' , ( ) => {
287
- let stepperComponent =
291
+ const stepperComponent =
288
292
fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
289
293
290
294
stepperComponent . selectedIndex = 1 ;
291
295
stepperComponent . steps . toArray ( ) [ 0 ] . editable = false ;
292
- let previousButtonNativeEl = fixture . debugElement
296
+ const previousButtonNativeEl = fixture . debugElement
293
297
. queryAll ( By . directive ( MatStepperPrevious ) ) [ 1 ] . nativeElement ;
294
298
previousButtonNativeEl . click ( ) ;
295
299
fixture . detectChanges ( ) ;
@@ -304,9 +308,9 @@ describe('MatStepper', () => {
304
308
} ) ;
305
309
306
310
it ( 'should set create icon if step is editable and completed' , ( ) => {
307
- let stepperComponent =
311
+ const stepperComponent =
308
312
fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
309
- let nextButtonNativeEl = fixture . debugElement
313
+ const nextButtonNativeEl = fixture . debugElement
310
314
. queryAll ( By . directive ( MatStepperNext ) ) [ 0 ] . nativeElement ;
311
315
expect ( stepperComponent . _getIndicatorType ( 0 ) ) . toBe ( 'number' ) ;
312
316
stepperComponent . steps . toArray ( ) [ 0 ] . editable = true ;
@@ -317,9 +321,9 @@ describe('MatStepper', () => {
317
321
} ) ;
318
322
319
323
it ( 'should set done icon if step is not editable and is completed' , ( ) => {
320
- let stepperComponent =
324
+ const stepperComponent =
321
325
fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
322
- let nextButtonNativeEl = fixture . debugElement
326
+ const nextButtonNativeEl = fixture . debugElement
323
327
. queryAll ( By . directive ( MatStepperNext ) ) [ 0 ] . nativeElement ;
324
328
expect ( stepperComponent . _getIndicatorType ( 0 ) ) . toBe ( 'number' ) ;
325
329
stepperComponent . steps . toArray ( ) [ 0 ] . editable = false ;
@@ -330,11 +334,11 @@ describe('MatStepper', () => {
330
334
} ) ;
331
335
332
336
it ( 'should emit an event when the enter animation is done' , fakeAsync ( ( ) => {
333
- let stepper = fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
334
- let selectionChangeSpy = jasmine . createSpy ( 'selectionChange spy' ) ;
335
- let animationDoneSpy = jasmine . createSpy ( 'animationDone spy' ) ;
336
- let selectionChangeSubscription = stepper . selectionChange . subscribe ( selectionChangeSpy ) ;
337
- let animationDoneSubscription = stepper . animationDone . subscribe ( animationDoneSpy ) ;
337
+ const stepper = fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
338
+ const selectionChangeSpy = jasmine . createSpy ( 'selectionChange spy' ) ;
339
+ const animationDoneSpy = jasmine . createSpy ( 'animationDone spy' ) ;
340
+ const selectionChangeSubscription = stepper . selectionChange . subscribe ( selectionChangeSpy ) ;
341
+ const animationDoneSubscription = stepper . animationDone . subscribe ( animationDoneSpy ) ;
338
342
339
343
stepper . selectedIndex = 1 ;
340
344
fixture . detectChanges ( ) ;
@@ -495,7 +499,7 @@ describe('MatStepper', () => {
495
499
} ) ;
496
500
497
501
it ( 'should reverse animation in RTL mode' , ( ) => {
498
- let stepperComponent =
502
+ const stepperComponent =
499
503
fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
500
504
501
505
expect ( stepperComponent . _getAnimationDirection ( 0 ) ) . toBe ( 'current' ) ;
@@ -543,15 +547,15 @@ describe('MatStepper', () => {
543
547
expect ( testComponent . oneGroup . invalid ) . toBe ( true ) ;
544
548
expect ( stepperComponent . selectedIndex ) . toBe ( 0 ) ;
545
549
546
- let stepHeaderEl = fixture . debugElement
550
+ const stepHeaderEl = fixture . debugElement
547
551
. queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) [ 1 ] . nativeElement ;
548
552
549
553
stepHeaderEl . click ( ) ;
550
554
fixture . detectChanges ( ) ;
551
555
552
556
expect ( stepperComponent . selectedIndex ) . toBe ( 0 ) ;
553
557
554
- let nextButtonNativeEl = fixture . debugElement
558
+ const nextButtonNativeEl = fixture . debugElement
555
559
. queryAll ( By . directive ( MatStepperNext ) ) [ 0 ] . nativeElement ;
556
560
nextButtonNativeEl . click ( ) ;
557
561
fixture . detectChanges ( ) ;
@@ -567,10 +571,10 @@ describe('MatStepper', () => {
567
571
} ) ;
568
572
569
573
it ( 'should not move to next step if current step is pending' , ( ) => {
570
- let stepHeaderEl = fixture . debugElement
574
+ const stepHeaderEl = fixture . debugElement
571
575
. queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) [ 2 ] . nativeElement ;
572
576
573
- let nextButtonNativeEl = fixture . debugElement
577
+ const nextButtonNativeEl = fixture . debugElement
574
578
. queryAll ( By . directive ( MatStepperNext ) ) [ 1 ] . nativeElement ;
575
579
576
580
testComponent . oneGroup . get ( 'oneCtrl' ) ! . setValue ( 'input' ) ;
@@ -616,7 +620,8 @@ describe('MatStepper', () => {
616
620
} ) ;
617
621
618
622
it ( 'should be able to focus step header upon click if it is unable to be selected' , ( ) => {
619
- let stepHeaderEl = fixture . debugElement . queryAll ( By . css ( 'mat-step-header' ) ) [ 1 ] . nativeElement ;
623
+ const stepHeaderEl =
624
+ fixture . debugElement . queryAll ( By . css ( 'mat-step-header' ) ) [ 1 ] . nativeElement ;
620
625
621
626
fixture . detectChanges ( ) ;
622
627
@@ -834,41 +839,42 @@ describe('MatStepper', () => {
834
839
835
840
describe ( 'vertical stepper' , ( ) => {
836
841
it ( 'should be able to use the legacy classes in queries' , ( ) => {
837
- let fixture = createComponent ( SimpleMatVerticalStepperApp ) ;
842
+ const fixture = createComponent ( SimpleMatVerticalStepperApp ) ;
838
843
fixture . detectChanges ( ) ;
844
+
839
845
expect ( fixture . componentInstance . legacyTokenStepper ) . toBeTruthy ( ) ;
840
846
} ) ;
841
847
842
848
it ( 'should set the aria-orientation to "vertical"' , ( ) => {
843
- let fixture = createComponent ( SimpleMatVerticalStepperApp ) ;
849
+ const fixture = createComponent ( SimpleMatVerticalStepperApp ) ;
844
850
fixture . detectChanges ( ) ;
845
851
846
- let stepperEl = fixture . debugElement . query ( By . css ( 'mat-stepper' ) ) ! . nativeElement ;
852
+ const stepperEl = fixture . debugElement . query ( By . css ( 'mat-stepper' ) ) ! . nativeElement ;
847
853
expect ( stepperEl . getAttribute ( 'aria-orientation' ) ) . toBe ( 'vertical' ) ;
848
854
} ) ;
849
855
850
856
it ( 'should support using the left/right arrows to move focus' , ( ) => {
851
- let fixture = createComponent ( SimpleMatVerticalStepperApp ) ;
857
+ const fixture = createComponent ( SimpleMatVerticalStepperApp ) ;
852
858
fixture . detectChanges ( ) ;
853
859
854
- let stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) ;
860
+ const stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) ;
855
861
assertCorrectKeyboardInteraction ( fixture , stepHeaders , 'horizontal' ) ;
856
862
} ) ;
857
863
858
864
it ( 'should support using the up/down arrows to move focus' , ( ) => {
859
- let fixture = createComponent ( SimpleMatVerticalStepperApp ) ;
865
+ const fixture = createComponent ( SimpleMatVerticalStepperApp ) ;
860
866
fixture . detectChanges ( ) ;
861
867
862
- let stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) ;
868
+ const stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) ;
863
869
assertCorrectKeyboardInteraction ( fixture , stepHeaders , 'vertical' ) ;
864
870
} ) ;
865
871
866
872
it ( 'should reverse arrow key focus in RTL mode' , ( ) => {
867
873
dir . value = 'rtl' ;
868
- let fixture = createComponent ( SimpleMatVerticalStepperApp ) ;
874
+ const fixture = createComponent ( SimpleMatVerticalStepperApp ) ;
869
875
fixture . detectChanges ( ) ;
870
876
871
- let stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) ;
877
+ const stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) ;
872
878
assertArrowKeyInteractionInRtl ( fixture , stepHeaders ) ;
873
879
} ) ;
874
880
@@ -941,41 +947,42 @@ describe('MatStepper', () => {
941
947
942
948
describe ( 'horizontal stepper' , ( ) => {
943
949
it ( 'should be able to use the legacy classes in queries' , ( ) => {
944
- let fixture = createComponent ( SimpleMatHorizontalStepperApp ) ;
950
+ const fixture = createComponent ( SimpleMatHorizontalStepperApp ) ;
945
951
fixture . detectChanges ( ) ;
952
+
946
953
expect ( fixture . componentInstance . legacyTokenStepper ) . toBeTruthy ( ) ;
947
954
} ) ;
948
955
949
956
it ( 'should set the aria-orientation to "horizontal"' , ( ) => {
950
- let fixture = createComponent ( SimpleMatHorizontalStepperApp ) ;
957
+ const fixture = createComponent ( SimpleMatHorizontalStepperApp ) ;
951
958
fixture . detectChanges ( ) ;
952
959
953
- let stepperEl = fixture . debugElement . query ( By . css ( 'mat-stepper' ) ) ! . nativeElement ;
960
+ const stepperEl = fixture . debugElement . query ( By . css ( 'mat-stepper' ) ) ! . nativeElement ;
954
961
expect ( stepperEl . getAttribute ( 'aria-orientation' ) ) . toBe ( 'horizontal' ) ;
955
962
} ) ;
956
963
957
964
it ( 'should support using the left/right arrows to move focus' , ( ) => {
958
- let fixture = createComponent ( SimpleMatHorizontalStepperApp ) ;
965
+ const fixture = createComponent ( SimpleMatHorizontalStepperApp ) ;
959
966
fixture . detectChanges ( ) ;
960
967
961
- let stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) ;
968
+ const stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) ;
962
969
assertCorrectKeyboardInteraction ( fixture , stepHeaders , 'horizontal' ) ;
963
970
} ) ;
964
971
965
972
it ( 'should reverse arrow key focus in RTL mode' , ( ) => {
966
973
dir . value = 'rtl' ;
967
- let fixture = createComponent ( SimpleMatHorizontalStepperApp ) ;
974
+ const fixture = createComponent ( SimpleMatHorizontalStepperApp ) ;
968
975
fixture . detectChanges ( ) ;
969
976
970
- let stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) ;
977
+ const stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) ;
971
978
assertArrowKeyInteractionInRtl ( fixture , stepHeaders ) ;
972
979
} ) ;
973
980
974
981
it ( 'should reverse arrow key focus when switching into RTL after init' , ( ) => {
975
- let fixture = createComponent ( SimpleMatHorizontalStepperApp ) ;
982
+ const fixture = createComponent ( SimpleMatHorizontalStepperApp ) ;
976
983
fixture . detectChanges ( ) ;
977
984
978
- let stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) ;
985
+ const stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) ;
979
986
assertCorrectKeyboardInteraction ( fixture , stepHeaders , 'horizontal' ) ;
980
987
981
988
dir . value = 'rtl' ;
@@ -1246,7 +1253,7 @@ describe('MatStepper', () => {
1246
1253
} ) ;
1247
1254
1248
1255
it ( 'should show done state when step is completed and its not the current step' , ( ) => {
1249
- let nextButtonNativeEl = fixture . debugElement
1256
+ const nextButtonNativeEl = fixture . debugElement
1250
1257
. queryAll ( By . directive ( MatStepperNext ) ) [ 0 ] . nativeElement ;
1251
1258
1252
1259
stepper . selectedIndex = 1 ;
@@ -1421,9 +1428,9 @@ describe('MatStepper', () => {
1421
1428
function assertCorrectKeyboardInteraction ( fixture : ComponentFixture < any > ,
1422
1429
stepHeaders : DebugElement [ ] ,
1423
1430
orientation : StepperOrientation ) {
1424
- let stepperComponent = fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
1425
- let nextKey = orientation === 'vertical' ? DOWN_ARROW : RIGHT_ARROW ;
1426
- let prevKey = orientation === 'vertical' ? UP_ARROW : LEFT_ARROW ;
1431
+ const stepperComponent = fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
1432
+ const nextKey = orientation === 'vertical' ? DOWN_ARROW : RIGHT_ARROW ;
1433
+ const prevKey = orientation === 'vertical' ? UP_ARROW : LEFT_ARROW ;
1427
1434
1428
1435
expect ( stepperComponent . _getFocusIndex ( ) ) . toBe ( 0 ) ;
1429
1436
expect ( stepperComponent . selectedIndex ) . toBe ( 0 ) ;
@@ -1492,7 +1499,7 @@ function assertCorrectKeyboardInteraction(fixture: ComponentFixture<any>,
1492
1499
/** Asserts that arrow key direction works correctly in RTL mode. */
1493
1500
function assertArrowKeyInteractionInRtl ( fixture : ComponentFixture < any > ,
1494
1501
stepHeaders : DebugElement [ ] ) {
1495
- let stepperComponent = fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
1502
+ const stepperComponent = fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
1496
1503
1497
1504
expect ( stepperComponent . _getFocusIndex ( ) ) . toBe ( 0 ) ;
1498
1505
0 commit comments