@@ -67,11 +67,11 @@ describe('MatStepperHarness', () => {
67
67
expect ( await parallel ( ( ) => steps . map ( step => step . getLabel ( ) ) ) ) . toEqual ( [ 'Two' , 'Four' ] ) ;
68
68
} ) ;
69
69
70
- it ( 'should be able to select a particular step that matches a filter' , async ( ) => {
70
+ it ( 'should be able to select a particular step that matches a filter on a vertical stepper ' , async ( ) => {
71
71
const stepper = await loader . getHarness ( MatStepperHarness . with ( { selector : '#one-stepper' } ) ) ;
72
72
const steps = await stepper . getSteps ( ) ;
73
73
74
- expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
74
+ expect ( await parallel ( ( ) => steps . map ( step => step . isExpanded ( ) ) ) ) . toEqual ( [
75
75
true ,
76
76
false ,
77
77
false ,
@@ -80,14 +80,33 @@ describe('MatStepperHarness', () => {
80
80
81
81
await stepper . selectStep ( { label : 'Three' } ) ;
82
82
83
- expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
83
+ expect ( await parallel ( ( ) => steps . map ( step => step . isExpanded ( ) ) ) ) . toEqual ( [
84
84
false ,
85
85
false ,
86
86
true ,
87
87
false ,
88
88
] ) ;
89
89
} ) ;
90
90
91
+ it ( 'should be able to select a particular step that matches a filter on a horizontal stepper' , async ( ) => {
92
+ const stepper = await loader . getHarness ( MatStepperHarness . with ( { selector : '#two-stepper' } ) ) ;
93
+ const steps = await stepper . getSteps ( ) ;
94
+
95
+ expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
96
+ true ,
97
+ false ,
98
+ false ,
99
+ ] ) ;
100
+
101
+ await stepper . selectStep ( { label : 'Three' } ) ;
102
+
103
+ expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
104
+ false ,
105
+ false ,
106
+ true ,
107
+ ] ) ;
108
+ } ) ;
109
+
91
110
it ( 'should be able to get the text-based label of a step' , async ( ) => {
92
111
const stepper = await loader . getHarness ( MatStepperHarness . with ( { selector : '#one-stepper' } ) ) ;
93
112
const steps = await stepper . getSteps ( ) ;
@@ -132,39 +151,69 @@ describe('MatStepperHarness', () => {
132
151
] ) ;
133
152
} ) ;
134
153
135
- it ( 'should get the selected state of a step' , async ( ) => {
154
+ it ( 'should get the expanded state of a step in a vertical stepper ' , async ( ) => {
136
155
const stepper = await loader . getHarness ( MatStepperHarness . with ( { selector : '#one-stepper' } ) ) ;
137
156
const steps = await stepper . getSteps ( ) ;
138
157
139
- expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
158
+ expect ( await parallel ( ( ) => steps . map ( step => step . isExpanded ( ) ) ) ) . toEqual ( [
140
159
true ,
141
160
false ,
142
161
false ,
143
162
false ,
144
163
] ) ;
145
164
} ) ;
146
165
147
- it ( 'should be able to select a step' , async ( ) => {
148
- const stepper = await loader . getHarness ( MatStepperHarness . with ( { selector : '#one -stepper' } ) ) ;
166
+ it ( 'should get the selected state of a step in a horizontal stepper ' , async ( ) => {
167
+ const stepper = await loader . getHarness ( MatStepperHarness . with ( { selector : '#two -stepper' } ) ) ;
149
168
const steps = await stepper . getSteps ( ) ;
150
169
151
170
expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
152
171
true ,
153
172
false ,
154
173
false ,
174
+ ] ) ;
175
+ } ) ;
176
+
177
+ it ( 'should be able to select a step in a vertical stepper' , async ( ) => {
178
+ const stepper = await loader . getHarness ( MatStepperHarness . with ( { selector : '#one-stepper' } ) ) ;
179
+ const steps = await stepper . getSteps ( ) ;
180
+
181
+ expect ( await parallel ( ( ) => steps . map ( step => step . isExpanded ( ) ) ) ) . toEqual ( [
182
+ true ,
183
+ false ,
184
+ false ,
155
185
false ,
156
186
] ) ;
157
187
158
188
await steps [ 2 ] . select ( ) ;
159
189
160
- expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
190
+ expect ( await parallel ( ( ) => steps . map ( step => step . isExpanded ( ) ) ) ) . toEqual ( [
161
191
false ,
162
192
false ,
163
193
true ,
164
194
false ,
165
195
] ) ;
166
196
} ) ;
167
197
198
+ it ( 'should be able to select a step in a horizontal stepper' , async ( ) => {
199
+ const stepper = await loader . getHarness ( MatStepperHarness . with ( { selector : '#two-stepper' } ) ) ;
200
+ const steps = await stepper . getSteps ( ) ;
201
+
202
+ expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
203
+ true ,
204
+ false ,
205
+ false ,
206
+ ] ) ;
207
+
208
+ await steps [ 2 ] . select ( ) ;
209
+
210
+ expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
211
+ false ,
212
+ false ,
213
+ true ,
214
+ ] ) ;
215
+ } ) ;
216
+
168
217
it ( 'should get whether a step is optional' , async ( ) => {
169
218
const stepper = await loader . getHarness ( MatStepperHarness . with ( { selector : '#two-stepper' } ) ) ;
170
219
const steps = await stepper . getSteps ( ) ;
@@ -183,15 +232,15 @@ describe('MatStepperHarness', () => {
183
232
expect ( await previousButton . getText ( ) ) . toBe ( 'Previous' ) ;
184
233
} ) ;
185
234
186
- it ( 'should go forward when pressing the next button' , async ( ) => {
235
+ it ( 'should go forward when pressing the next button in a vertical stepper ' , async ( ) => {
187
236
const stepper = await loader . getHarness ( MatStepperHarness . with ( { selector : '#one-stepper' } ) ) ;
188
237
const steps = await stepper . getSteps ( ) ;
189
238
const secondStep = steps [ 1 ] ;
190
239
const nextButton = await secondStep . getHarness ( MatStepperNextHarness ) ;
191
240
192
241
await secondStep . select ( ) ;
193
242
194
- expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
243
+ expect ( await parallel ( ( ) => steps . map ( step => step . isExpanded ( ) ) ) ) . toEqual ( [
195
244
false ,
196
245
true ,
197
246
false ,
@@ -200,23 +249,46 @@ describe('MatStepperHarness', () => {
200
249
201
250
await nextButton . click ( ) ;
202
251
203
- expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
252
+ expect ( await parallel ( ( ) => steps . map ( step => step . isExpanded ( ) ) ) ) . toEqual ( [
204
253
false ,
205
254
false ,
206
255
true ,
207
256
false ,
208
257
] ) ;
209
258
} ) ;
210
259
211
- it ( 'should go backward when pressing the previous button' , async ( ) => {
260
+ it ( 'should go forward when pressing the next button in a horizontal stepper' , async ( ) => {
261
+ const stepper = await loader . getHarness ( MatStepperHarness . with ( { selector : '#two-stepper' } ) ) ;
262
+ const steps = await stepper . getSteps ( ) ;
263
+ const secondStep = steps [ 1 ] ;
264
+ const nextButton = await secondStep . getHarness ( MatStepperNextHarness ) ;
265
+
266
+ await secondStep . select ( ) ;
267
+
268
+ expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
269
+ false ,
270
+ true ,
271
+ false ,
272
+ ] ) ;
273
+
274
+ await nextButton . click ( ) ;
275
+
276
+ expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
277
+ false ,
278
+ false ,
279
+ true ,
280
+ ] ) ;
281
+ } ) ;
282
+
283
+ it ( 'should go backward when pressing the previous button of a vertical stepper' , async ( ) => {
212
284
const stepper = await loader . getHarness ( MatStepperHarness . with ( { selector : '#one-stepper' } ) ) ;
213
285
const steps = await stepper . getSteps ( ) ;
214
286
const secondStep = steps [ 1 ] ;
215
287
const previousButton = await secondStep . getHarness ( MatStepperPreviousHarness ) ;
216
288
217
289
await secondStep . select ( ) ;
218
290
219
- expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
291
+ expect ( await parallel ( ( ) => steps . map ( step => step . isExpanded ( ) ) ) ) . toEqual ( [
220
292
false ,
221
293
true ,
222
294
false ,
@@ -225,9 +297,32 @@ describe('MatStepperHarness', () => {
225
297
226
298
await previousButton . click ( ) ;
227
299
300
+ expect ( await parallel ( ( ) => steps . map ( step => step . isExpanded ( ) ) ) ) . toEqual ( [
301
+ true ,
302
+ false ,
303
+ false ,
304
+ false ,
305
+ ] ) ;
306
+ } ) ;
307
+
308
+ it ( 'should go backward when pressing the previous button of a horizontal stepper' , async ( ) => {
309
+ const stepper = await loader . getHarness ( MatStepperHarness . with ( { selector : '#two-stepper' } ) ) ;
310
+ const steps = await stepper . getSteps ( ) ;
311
+ const secondStep = steps [ 1 ] ;
312
+ const previousButton = await secondStep . getHarness ( MatStepperPreviousHarness ) ;
313
+
314
+ await secondStep . select ( ) ;
315
+
228
316
expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
317
+ false ,
229
318
true ,
230
319
false ,
320
+ ] ) ;
321
+
322
+ await previousButton . click ( ) ;
323
+
324
+ expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
325
+ true ,
231
326
false ,
232
327
false ,
233
328
] ) ;
@@ -279,12 +374,16 @@ describe('MatStepperHarness', () => {
279
374
<mat-stepper id="two-stepper">
280
375
<mat-step>
281
376
<ng-template matStepLabel>One</ng-template>
377
+ <button matStepperNext>Next</button>
282
378
</mat-step>
283
379
<mat-step optional>
284
380
<ng-template matStepLabel>Two</ng-template>
381
+ <button matStepperPrevious>Previous</button>
382
+ <button matStepperNext>Next</button>
285
383
</mat-step>
286
384
<mat-step optional>
287
385
<ng-template matStepLabel>Three</ng-template>
386
+ <button matStepperPrevious>Previous</button>
288
387
</mat-step>
289
388
</mat-stepper>
290
389
0 commit comments