@@ -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,10 @@ 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 = fixture . debugElement . queryAll ( By . css ( 'mat-step-header' ) ) [ 1 ] . nativeElement ;
263
+ const nextButtonNativeEl = fixture . debugElement
262
264
. queryAll ( By . directive ( MatStepperNext ) ) [ 0 ] . nativeElement ;
263
265
spyOn ( stepHeaderEl , 'focus' ) ;
264
266
nextButtonNativeEl . click ( ) ;
@@ -269,10 +271,10 @@ describe('MatStepper', () => {
269
271
} ) ;
270
272
271
273
it ( 'should focus next step header if focus is inside the stepper' , ( ) => {
272
- let stepperComponent =
274
+ const stepperComponent =
273
275
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
276
+ const stepHeaderEl = fixture . debugElement . queryAll ( By . css ( 'mat-step-header' ) ) [ 1 ] . nativeElement ;
277
+ const nextButtonNativeEl = fixture . debugElement
276
278
. queryAll ( By . directive ( MatStepperNext ) ) [ 0 ] . nativeElement ;
277
279
spyOn ( stepHeaderEl , 'focus' ) ;
278
280
nextButtonNativeEl . focus ( ) ;
@@ -284,12 +286,12 @@ describe('MatStepper', () => {
284
286
} ) ;
285
287
286
288
it ( 'should only be able to return to a previous step if it is editable' , ( ) => {
287
- let stepperComponent =
289
+ const stepperComponent =
288
290
fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
289
291
290
292
stepperComponent . selectedIndex = 1 ;
291
293
stepperComponent . steps . toArray ( ) [ 0 ] . editable = false ;
292
- let previousButtonNativeEl = fixture . debugElement
294
+ const previousButtonNativeEl = fixture . debugElement
293
295
. queryAll ( By . directive ( MatStepperPrevious ) ) [ 1 ] . nativeElement ;
294
296
previousButtonNativeEl . click ( ) ;
295
297
fixture . detectChanges ( ) ;
@@ -304,9 +306,9 @@ describe('MatStepper', () => {
304
306
} ) ;
305
307
306
308
it ( 'should set create icon if step is editable and completed' , ( ) => {
307
- let stepperComponent =
309
+ const stepperComponent =
308
310
fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
309
- let nextButtonNativeEl = fixture . debugElement
311
+ const nextButtonNativeEl = fixture . debugElement
310
312
. queryAll ( By . directive ( MatStepperNext ) ) [ 0 ] . nativeElement ;
311
313
expect ( stepperComponent . _getIndicatorType ( 0 ) ) . toBe ( 'number' ) ;
312
314
stepperComponent . steps . toArray ( ) [ 0 ] . editable = true ;
@@ -317,9 +319,9 @@ describe('MatStepper', () => {
317
319
} ) ;
318
320
319
321
it ( 'should set done icon if step is not editable and is completed' , ( ) => {
320
- let stepperComponent =
322
+ const stepperComponent =
321
323
fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
322
- let nextButtonNativeEl = fixture . debugElement
324
+ const nextButtonNativeEl = fixture . debugElement
323
325
. queryAll ( By . directive ( MatStepperNext ) ) [ 0 ] . nativeElement ;
324
326
expect ( stepperComponent . _getIndicatorType ( 0 ) ) . toBe ( 'number' ) ;
325
327
stepperComponent . steps . toArray ( ) [ 0 ] . editable = false ;
@@ -330,11 +332,11 @@ describe('MatStepper', () => {
330
332
} ) ;
331
333
332
334
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 ) ;
335
+ const stepper = fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
336
+ const selectionChangeSpy = jasmine . createSpy ( 'selectionChange spy' ) ;
337
+ const animationDoneSpy = jasmine . createSpy ( 'animationDone spy' ) ;
338
+ const selectionChangeSubscription = stepper . selectionChange . subscribe ( selectionChangeSpy ) ;
339
+ const animationDoneSubscription = stepper . animationDone . subscribe ( animationDoneSpy ) ;
338
340
339
341
stepper . selectedIndex = 1 ;
340
342
fixture . detectChanges ( ) ;
@@ -495,7 +497,7 @@ describe('MatStepper', () => {
495
497
} ) ;
496
498
497
499
it ( 'should reverse animation in RTL mode' , ( ) => {
498
- let stepperComponent =
500
+ const stepperComponent =
499
501
fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
500
502
501
503
expect ( stepperComponent . _getAnimationDirection ( 0 ) ) . toBe ( 'current' ) ;
@@ -543,15 +545,15 @@ describe('MatStepper', () => {
543
545
expect ( testComponent . oneGroup . invalid ) . toBe ( true ) ;
544
546
expect ( stepperComponent . selectedIndex ) . toBe ( 0 ) ;
545
547
546
- let stepHeaderEl = fixture . debugElement
548
+ const stepHeaderEl = fixture . debugElement
547
549
. queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) [ 1 ] . nativeElement ;
548
550
549
551
stepHeaderEl . click ( ) ;
550
552
fixture . detectChanges ( ) ;
551
553
552
554
expect ( stepperComponent . selectedIndex ) . toBe ( 0 ) ;
553
555
554
- let nextButtonNativeEl = fixture . debugElement
556
+ const nextButtonNativeEl = fixture . debugElement
555
557
. queryAll ( By . directive ( MatStepperNext ) ) [ 0 ] . nativeElement ;
556
558
nextButtonNativeEl . click ( ) ;
557
559
fixture . detectChanges ( ) ;
@@ -567,10 +569,10 @@ describe('MatStepper', () => {
567
569
} ) ;
568
570
569
571
it ( 'should not move to next step if current step is pending' , ( ) => {
570
- let stepHeaderEl = fixture . debugElement
572
+ const stepHeaderEl = fixture . debugElement
571
573
. queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) [ 2 ] . nativeElement ;
572
574
573
- let nextButtonNativeEl = fixture . debugElement
575
+ const nextButtonNativeEl = fixture . debugElement
574
576
. queryAll ( By . directive ( MatStepperNext ) ) [ 1 ] . nativeElement ;
575
577
576
578
testComponent . oneGroup . get ( 'oneCtrl' ) ! . setValue ( 'input' ) ;
@@ -616,7 +618,8 @@ describe('MatStepper', () => {
616
618
} ) ;
617
619
618
620
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 ;
621
+ const stepHeaderEl =
622
+ fixture . debugElement . queryAll ( By . css ( 'mat-step-header' ) ) [ 1 ] . nativeElement ;
620
623
621
624
fixture . detectChanges ( ) ;
622
625
@@ -834,41 +837,42 @@ describe('MatStepper', () => {
834
837
835
838
describe ( 'vertical stepper' , ( ) => {
836
839
it ( 'should be able to use the legacy classes in queries' , ( ) => {
837
- let fixture = createComponent ( SimpleMatVerticalStepperApp ) ;
840
+ const fixture = createComponent ( SimpleMatVerticalStepperApp ) ;
838
841
fixture . detectChanges ( ) ;
842
+
839
843
expect ( fixture . componentInstance . legacyTokenStepper ) . toBeTruthy ( ) ;
840
844
} ) ;
841
845
842
846
it ( 'should set the aria-orientation to "vertical"' , ( ) => {
843
- let fixture = createComponent ( SimpleMatVerticalStepperApp ) ;
847
+ const fixture = createComponent ( SimpleMatVerticalStepperApp ) ;
844
848
fixture . detectChanges ( ) ;
845
849
846
- let stepperEl = fixture . debugElement . query ( By . css ( 'mat-stepper' ) ) ! . nativeElement ;
850
+ const stepperEl = fixture . debugElement . query ( By . css ( 'mat-stepper' ) ) ! . nativeElement ;
847
851
expect ( stepperEl . getAttribute ( 'aria-orientation' ) ) . toBe ( 'vertical' ) ;
848
852
} ) ;
849
853
850
854
it ( 'should support using the left/right arrows to move focus' , ( ) => {
851
- let fixture = createComponent ( SimpleMatVerticalStepperApp ) ;
855
+ const fixture = createComponent ( SimpleMatVerticalStepperApp ) ;
852
856
fixture . detectChanges ( ) ;
853
857
854
- let stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) ;
858
+ const stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) ;
855
859
assertCorrectKeyboardInteraction ( fixture , stepHeaders , 'horizontal' ) ;
856
860
} ) ;
857
861
858
862
it ( 'should support using the up/down arrows to move focus' , ( ) => {
859
- let fixture = createComponent ( SimpleMatVerticalStepperApp ) ;
863
+ const fixture = createComponent ( SimpleMatVerticalStepperApp ) ;
860
864
fixture . detectChanges ( ) ;
861
865
862
- let stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) ;
866
+ const stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) ;
863
867
assertCorrectKeyboardInteraction ( fixture , stepHeaders , 'vertical' ) ;
864
868
} ) ;
865
869
866
870
it ( 'should reverse arrow key focus in RTL mode' , ( ) => {
867
871
dir . value = 'rtl' ;
868
- let fixture = createComponent ( SimpleMatVerticalStepperApp ) ;
872
+ const fixture = createComponent ( SimpleMatVerticalStepperApp ) ;
869
873
fixture . detectChanges ( ) ;
870
874
871
- let stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) ;
875
+ const stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) ;
872
876
assertArrowKeyInteractionInRtl ( fixture , stepHeaders ) ;
873
877
} ) ;
874
878
@@ -941,41 +945,42 @@ describe('MatStepper', () => {
941
945
942
946
describe ( 'horizontal stepper' , ( ) => {
943
947
it ( 'should be able to use the legacy classes in queries' , ( ) => {
944
- let fixture = createComponent ( SimpleMatHorizontalStepperApp ) ;
948
+ const fixture = createComponent ( SimpleMatHorizontalStepperApp ) ;
945
949
fixture . detectChanges ( ) ;
950
+
946
951
expect ( fixture . componentInstance . legacyTokenStepper ) . toBeTruthy ( ) ;
947
952
} ) ;
948
953
949
954
it ( 'should set the aria-orientation to "horizontal"' , ( ) => {
950
- let fixture = createComponent ( SimpleMatHorizontalStepperApp ) ;
955
+ const fixture = createComponent ( SimpleMatHorizontalStepperApp ) ;
951
956
fixture . detectChanges ( ) ;
952
957
953
- let stepperEl = fixture . debugElement . query ( By . css ( 'mat-stepper' ) ) ! . nativeElement ;
958
+ const stepperEl = fixture . debugElement . query ( By . css ( 'mat-stepper' ) ) ! . nativeElement ;
954
959
expect ( stepperEl . getAttribute ( 'aria-orientation' ) ) . toBe ( 'horizontal' ) ;
955
960
} ) ;
956
961
957
962
it ( 'should support using the left/right arrows to move focus' , ( ) => {
958
- let fixture = createComponent ( SimpleMatHorizontalStepperApp ) ;
963
+ const fixture = createComponent ( SimpleMatHorizontalStepperApp ) ;
959
964
fixture . detectChanges ( ) ;
960
965
961
- let stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) ;
966
+ const stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) ;
962
967
assertCorrectKeyboardInteraction ( fixture , stepHeaders , 'horizontal' ) ;
963
968
} ) ;
964
969
965
970
it ( 'should reverse arrow key focus in RTL mode' , ( ) => {
966
971
dir . value = 'rtl' ;
967
- let fixture = createComponent ( SimpleMatHorizontalStepperApp ) ;
972
+ const fixture = createComponent ( SimpleMatHorizontalStepperApp ) ;
968
973
fixture . detectChanges ( ) ;
969
974
970
- let stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) ;
975
+ const stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) ;
971
976
assertArrowKeyInteractionInRtl ( fixture , stepHeaders ) ;
972
977
} ) ;
973
978
974
979
it ( 'should reverse arrow key focus when switching into RTL after init' , ( ) => {
975
- let fixture = createComponent ( SimpleMatHorizontalStepperApp ) ;
980
+ const fixture = createComponent ( SimpleMatHorizontalStepperApp ) ;
976
981
fixture . detectChanges ( ) ;
977
982
978
- let stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) ;
983
+ const stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) ;
979
984
assertCorrectKeyboardInteraction ( fixture , stepHeaders , 'horizontal' ) ;
980
985
981
986
dir . value = 'rtl' ;
@@ -1246,7 +1251,7 @@ describe('MatStepper', () => {
1246
1251
} ) ;
1247
1252
1248
1253
it ( 'should show done state when step is completed and its not the current step' , ( ) => {
1249
- let nextButtonNativeEl = fixture . debugElement
1254
+ const nextButtonNativeEl = fixture . debugElement
1250
1255
. queryAll ( By . directive ( MatStepperNext ) ) [ 0 ] . nativeElement ;
1251
1256
1252
1257
stepper . selectedIndex = 1 ;
@@ -1421,9 +1426,9 @@ describe('MatStepper', () => {
1421
1426
function assertCorrectKeyboardInteraction ( fixture : ComponentFixture < any > ,
1422
1427
stepHeaders : DebugElement [ ] ,
1423
1428
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 ;
1429
+ const stepperComponent = fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
1430
+ const nextKey = orientation === 'vertical' ? DOWN_ARROW : RIGHT_ARROW ;
1431
+ const prevKey = orientation === 'vertical' ? UP_ARROW : LEFT_ARROW ;
1427
1432
1428
1433
expect ( stepperComponent . _getFocusIndex ( ) ) . toBe ( 0 ) ;
1429
1434
expect ( stepperComponent . selectedIndex ) . toBe ( 0 ) ;
@@ -1492,7 +1497,7 @@ function assertCorrectKeyboardInteraction(fixture: ComponentFixture<any>,
1492
1497
/** Asserts that arrow key direction works correctly in RTL mode. */
1493
1498
function assertArrowKeyInteractionInRtl ( fixture : ComponentFixture < any > ,
1494
1499
stepHeaders : DebugElement [ ] ) {
1495
- let stepperComponent = fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
1500
+ const stepperComponent = fixture . debugElement . query ( By . directive ( MatStepper ) ) ! . componentInstance ;
1496
1501
1497
1502
expect ( stepperComponent . _getFocusIndex ( ) ) . toBe ( 0 ) ;
1498
1503
0 commit comments