@@ -5,15 +5,15 @@ import {By} from '@angular/platform-browser';
5
5
import { MdHorizontalStepper } from './stepper-horizontal' ;
6
6
import { MdVerticalStepper } from './stepper-vertical' ;
7
7
import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
8
- import { FormControl , FormGroup , FormsModule , ReactiveFormsModule , Validators } from '@angular/forms' ;
8
+ import { FormControl , FormGroup , ReactiveFormsModule , Validators } from '@angular/forms' ;
9
9
import { MdStepperNext , MdStepperPrevious } from './stepper-button' ;
10
10
import { dispatchKeyboardEvent } from '@angular/cdk/testing' ;
11
11
import { ENTER , LEFT_ARROW , RIGHT_ARROW , SPACE } from '@angular/cdk/keycodes' ;
12
12
13
- fdescribe ( 'MdHorizontalStepper' , ( ) => {
13
+ describe ( 'MdHorizontalStepper' , ( ) => {
14
14
beforeEach ( async ( ( ) => {
15
15
TestBed . configureTestingModule ( {
16
- imports : [ MdStepperModule , NoopAnimationsModule , FormsModule , ReactiveFormsModule ] ,
16
+ imports : [ MdStepperModule , NoopAnimationsModule , ReactiveFormsModule ] ,
17
17
declarations : [
18
18
SimpleMdHorizontalStepperApp ,
19
19
LinearMdHorizontalStepperApp
@@ -41,8 +41,8 @@ fdescribe('MdHorizontalStepper', () => {
41
41
} ) ;
42
42
43
43
it ( 'should change selected index on header click' , ( ) => {
44
- let stepHeader = fixture . debugElement . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) ;
45
- checkSelectionChangeOnHeaderClick ( stepperComponent , fixture , stepHeader ) ;
44
+ let stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) ;
45
+ checkSelectionChangeOnHeaderClick ( stepperComponent , fixture , stepHeaders ) ;
46
46
47
47
} ) ;
48
48
@@ -51,9 +51,9 @@ fdescribe('MdHorizontalStepper', () => {
51
51
expect ( stepperEl . getAttribute ( 'role' ) ) . toBe ( 'tablist' ) ;
52
52
} ) ;
53
53
54
- it ( 'should expand the right content' , ( ) => {
55
- let stepContent = fixture . debugElement . queryAll ( By . css ( `.mat-horizontal-stepper-content` ) ) ;
56
- checkExpandedContent ( stepperComponent , fixture , stepContent ) ;
54
+ it ( 'should set aria-expanded of content correctly ' , ( ) => {
55
+ let stepContents = fixture . debugElement . queryAll ( By . css ( `.mat-horizontal-stepper-content` ) ) ;
56
+ checkExpandedContent ( stepperComponent , fixture , stepContents ) ;
57
57
} ) ;
58
58
59
59
it ( 'should display the correct label' , ( ) => {
@@ -73,8 +73,8 @@ fdescribe('MdHorizontalStepper', () => {
73
73
} ) ;
74
74
75
75
it ( 'should support keyboard events to move and select focus' , ( ) => {
76
- let stepHeader = fixture . debugElement . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) ;
77
- checkKeyboardEvent ( stepperComponent , fixture , stepHeader ) ;
76
+ let stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) ;
77
+ checkKeyboardEvent ( stepperComponent , fixture , stepHeaders ) ;
78
78
} ) ;
79
79
} ) ;
80
80
@@ -98,6 +98,7 @@ fdescribe('MdHorizontalStepper', () => {
98
98
99
99
it ( 'should not move to next step if current step is not valid' , ( ) => {
100
100
expect ( testComponent . oneGroup . get ( 'oneCtrl' ) ! . value ) . toBe ( '' ) ;
101
+ expect ( testComponent . oneGroup . get ( 'oneCtrl' ) ! . valid ) . toBe ( false ) ;
101
102
expect ( testComponent . oneGroup . valid ) . toBe ( false ) ;
102
103
expect ( stepperComponent . selectedIndex ) . toBe ( 0 ) ;
103
104
@@ -108,10 +109,10 @@ fdescribe('MdHorizontalStepper', () => {
108
109
} ) ;
109
110
} ) ;
110
111
111
- fdescribe ( 'MdVerticalStepper' , ( ) => {
112
+ describe ( 'MdVerticalStepper' , ( ) => {
112
113
beforeEach ( async ( ( ) => {
113
114
TestBed . configureTestingModule ( {
114
- imports : [ MdStepperModule , NoopAnimationsModule , FormsModule , ReactiveFormsModule ] ,
115
+ imports : [ MdStepperModule , NoopAnimationsModule , ReactiveFormsModule ] ,
115
116
declarations : [
116
117
SimpleMdVerticalStepperApp ,
117
118
LinearMdVerticalStepperApp
@@ -139,8 +140,8 @@ fdescribe('MdVerticalStepper', () => {
139
140
} ) ;
140
141
141
142
it ( 'should change selected index on header click' , ( ) => {
142
- let stepHeader = fixture . debugElement . queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) ;
143
- checkSelectionChangeOnHeaderClick ( stepperComponent , fixture , stepHeader ) ;
143
+ let stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) ;
144
+ checkSelectionChangeOnHeaderClick ( stepperComponent , fixture , stepHeaders ) ;
144
145
145
146
} ) ;
146
147
@@ -149,9 +150,9 @@ fdescribe('MdVerticalStepper', () => {
149
150
expect ( stepperEl . getAttribute ( 'role' ) ) . toBe ( 'tablist' ) ;
150
151
} ) ;
151
152
152
- it ( 'should expand the right content' , ( ) => {
153
- let stepContent = fixture . debugElement . queryAll ( By . css ( `.mat-vertical-stepper-content` ) ) ;
154
- checkExpandedContent ( stepperComponent , fixture , stepContent ) ;
153
+ it ( 'should set aria-expanded of content correctly ' , ( ) => {
154
+ let stepContents = fixture . debugElement . queryAll ( By . css ( `.mat-vertical-stepper-content` ) ) ;
155
+ checkExpandedContent ( stepperComponent , fixture , stepContents ) ;
155
156
} ) ;
156
157
157
158
it ( 'should display the correct label' , ( ) => {
@@ -171,8 +172,8 @@ fdescribe('MdVerticalStepper', () => {
171
172
} ) ;
172
173
173
174
it ( 'should support keyboard events to move and select focus' , ( ) => {
174
- let stepHeader = fixture . debugElement . queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) ;
175
- checkKeyboardEvent ( stepperComponent , fixture , stepHeader ) ;
175
+ let stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) ;
176
+ checkKeyboardEvent ( stepperComponent , fixture , stepHeaders ) ;
176
177
} ) ;
177
178
} ) ;
178
179
@@ -196,6 +197,7 @@ fdescribe('MdVerticalStepper', () => {
196
197
197
198
it ( 'should not move to next step if current step is not valid' , ( ) => {
198
199
expect ( testComponent . oneGroup . get ( 'oneCtrl' ) ! . value ) . toBe ( '' ) ;
200
+ expect ( testComponent . oneGroup . get ( 'oneCtrl' ) ! . valid ) . toBe ( false ) ;
199
201
expect ( testComponent . oneGroup . valid ) . toBe ( false ) ;
200
202
expect ( stepperComponent . selectedIndex ) . toBe ( 0 ) ;
201
203
@@ -210,18 +212,18 @@ fdescribe('MdVerticalStepper', () => {
210
212
function checkSelectionChangeOnHeaderClick ( stepperComponent :
211
213
MdHorizontalStepper | MdVerticalStepper ,
212
214
fixture : ComponentFixture < any > ,
213
- stepHeader : DebugElement [ ] ) {
215
+ stepHeaders : DebugElement [ ] ) {
214
216
expect ( stepperComponent . selectedIndex ) . toBe ( 0 ) ;
215
217
216
218
// select the second step
217
- let stepHeaderEl = stepHeader [ 1 ] . nativeElement ;
219
+ let stepHeaderEl = stepHeaders [ 1 ] . nativeElement ;
218
220
stepHeaderEl . click ( ) ;
219
221
fixture . detectChanges ( ) ;
220
222
221
223
expect ( stepperComponent . selectedIndex ) . toBe ( 1 ) ;
222
224
223
225
// select the third step
224
- stepHeaderEl = stepHeader [ 2 ] . nativeElement ;
226
+ stepHeaderEl = stepHeaders [ 2 ] . nativeElement ;
225
227
stepHeaderEl . click ( ) ;
226
228
fixture . detectChanges ( ) ;
227
229
@@ -230,16 +232,16 @@ function checkSelectionChangeOnHeaderClick(stepperComponent:
230
232
231
233
function checkExpandedContent ( stepperComponent : MdHorizontalStepper | MdVerticalStepper ,
232
234
fixture : ComponentFixture < any > ,
233
- stepContent : DebugElement [ ] ) {
234
- let stepContentEl = stepContent [ 0 ] . nativeElement ;
235
- expect ( stepContentEl . getAttribute ( 'aria-expanded' ) ) . toBe ( 'true' ) ;
235
+ stepContents : DebugElement [ ] ) {
236
+ let firstStepContentEl = stepContents [ 0 ] . nativeElement ;
237
+ expect ( firstStepContentEl . getAttribute ( 'aria-expanded' ) ) . toBe ( 'true' ) ;
236
238
237
239
stepperComponent . selectedIndex = 1 ;
238
240
fixture . detectChanges ( ) ;
239
241
240
- expect ( stepContentEl . getAttribute ( 'aria-expanded' ) ) . toBe ( 'false' ) ;
241
- stepContentEl = stepContent [ 1 ] . nativeElement ;
242
- expect ( stepContentEl . getAttribute ( 'aria-expanded' ) ) . toBe ( 'true' ) ;
242
+ expect ( firstStepContentEl . getAttribute ( 'aria-expanded' ) ) . toBe ( 'false' ) ;
243
+ let secondStepContentEl = stepContents [ 1 ] . nativeElement ;
244
+ expect ( secondStepContentEl . getAttribute ( 'aria-expanded' ) ) . toBe ( 'true' ) ;
243
245
}
244
246
245
247
function checkCorrectLabel ( stepperComponent : MdHorizontalStepper | MdVerticalStepper ,
@@ -336,47 +338,60 @@ function checkStepPosition(stepperComponent: MdHorizontalStepper | MdVerticalSte
336
338
337
339
function checkKeyboardEvent ( stepperComponent : MdHorizontalStepper | MdVerticalStepper ,
338
340
fixture : ComponentFixture < any > ,
339
- stepHeader : DebugElement [ ] ) {
341
+ stepHeaders : DebugElement [ ] ) {
340
342
expect ( stepperComponent . _focusIndex ) . toBe ( 0 ) ;
341
343
expect ( stepperComponent . selectedIndex ) . toBe ( 0 ) ;
342
344
343
- let stepHeaderEl = stepHeader [ 0 ] . nativeElement ;
345
+ let stepHeaderEl = stepHeaders [ 0 ] . nativeElement ;
344
346
dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , RIGHT_ARROW ) ;
345
347
fixture . detectChanges ( ) ;
346
348
347
- expect ( stepperComponent . _focusIndex ) . toBe ( 1 ) ;
348
- expect ( stepperComponent . selectedIndex ) . toBe ( 0 ) ;
349
+ expect ( stepperComponent . _focusIndex )
350
+ . toBe ( 1 , 'Expected index of focused step to be increased by 1 after RIGHT_ARROW event.' ) ;
351
+ expect ( stepperComponent . selectedIndex )
352
+ . toBe ( 0 , 'Expected index of selected step to remain unchanged after RIGHT_ARROW event.' ) ;
349
353
350
- stepHeaderEl = stepHeader [ 1 ] . nativeElement ;
354
+ stepHeaderEl = stepHeaders [ 1 ] . nativeElement ;
351
355
dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , ENTER ) ;
352
356
fixture . detectChanges ( ) ;
353
357
354
- expect ( stepperComponent . _focusIndex ) . toBe ( 1 ) ;
355
- expect ( stepperComponent . selectedIndex ) . toBe ( 1 ) ;
358
+ expect ( stepperComponent . _focusIndex )
359
+ . toBe ( 1 , 'Expected index of focused step to remain unchanged after ENTER event.' ) ;
360
+ expect ( stepperComponent . selectedIndex )
361
+ . toBe ( 1 ,
362
+ 'Expected index of selected step to change to index of focused step after EVENT event.' ) ;
356
363
357
- stepHeaderEl = stepHeader [ 1 ] . nativeElement ;
364
+ stepHeaderEl = stepHeaders [ 1 ] . nativeElement ;
358
365
dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , LEFT_ARROW ) ;
359
366
fixture . detectChanges ( ) ;
360
367
361
- expect ( stepperComponent . _focusIndex ) . toBe ( 0 ) ;
362
- expect ( stepperComponent . selectedIndex ) . toBe ( 1 ) ;
368
+ expect ( stepperComponent . _focusIndex )
369
+ . toBe ( 0 , 'Expected index of focused step to decrease by 1 after LEFT_ARROW event.' ) ;
370
+ expect ( stepperComponent . selectedIndex )
371
+ . toBe ( 1 , 'Expected index of selected step to remain unchanged after LEFT_ARROW event.' ) ;
363
372
364
373
// When the focus is on the last step and right arrow key is pressed, the focus should cycle
365
374
// through to the first step.
366
375
stepperComponent . _focusIndex = 2 ;
367
- stepHeaderEl = stepHeader [ 2 ] . nativeElement ;
376
+ stepHeaderEl = stepHeaders [ 2 ] . nativeElement ;
368
377
dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , RIGHT_ARROW ) ;
369
378
fixture . detectChanges ( ) ;
370
379
371
- expect ( stepperComponent . _focusIndex ) . toBe ( 0 ) ;
372
- expect ( stepperComponent . selectedIndex ) . toBe ( 1 ) ;
380
+ expect ( stepperComponent . _focusIndex )
381
+ . toBe ( 0 ,
382
+ 'Expected index of focused step to cycle through to index 0 after RIGHT_ARROW event.' ) ;
383
+ expect ( stepperComponent . selectedIndex )
384
+ . toBe ( 1 , 'Expected index of selected step to remain unchanged after RIGHT_ARROW event.' ) ;
373
385
374
- stepHeaderEl = stepHeader [ 0 ] . nativeElement ;
386
+ stepHeaderEl = stepHeaders [ 0 ] . nativeElement ;
375
387
dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , SPACE ) ;
376
388
fixture . detectChanges ( ) ;
377
389
378
- expect ( stepperComponent . _focusIndex ) . toBe ( 0 ) ;
379
- expect ( stepperComponent . selectedIndex ) . toBe ( 0 ) ;
390
+ expect ( stepperComponent . _focusIndex )
391
+ . toBe ( 0 , 'Expected index of focused to remain unchanged after SPACE event.' ) ;
392
+ expect ( stepperComponent . selectedIndex )
393
+ . toBe ( 0 ,
394
+ 'Expected index of selected step to change to index of focused step after SPACE event.' ) ;
380
395
}
381
396
382
397
function checkLinearStepperValidity ( stepHeaderEl : HTMLElement ,
0 commit comments