@@ -67,11 +67,11 @@ describe('MatStepperHarness', () => {
6767 expect ( await parallel ( ( ) => steps . map ( step => step . getLabel ( ) ) ) ) . toEqual ( [ 'Two' , 'Four' ] ) ;
6868 } ) ;
6969
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 ( ) => {
7171 const stepper = await loader . getHarness ( MatStepperHarness . with ( { selector : '#one-stepper' } ) ) ;
7272 const steps = await stepper . getSteps ( ) ;
7373
74- expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
74+ expect ( await parallel ( ( ) => steps . map ( step => step . isExpanded ( ) ) ) ) . toEqual ( [
7575 true ,
7676 false ,
7777 false ,
@@ -80,14 +80,33 @@ describe('MatStepperHarness', () => {
8080
8181 await stepper . selectStep ( { label : 'Three' } ) ;
8282
83- expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
83+ expect ( await parallel ( ( ) => steps . map ( step => step . isExpanded ( ) ) ) ) . toEqual ( [
8484 false ,
8585 false ,
8686 true ,
8787 false ,
8888 ] ) ;
8989 } ) ;
9090
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+
91110 it ( 'should be able to get the text-based label of a step' , async ( ) => {
92111 const stepper = await loader . getHarness ( MatStepperHarness . with ( { selector : '#one-stepper' } ) ) ;
93112 const steps = await stepper . getSteps ( ) ;
@@ -132,39 +151,69 @@ describe('MatStepperHarness', () => {
132151 ] ) ;
133152 } ) ;
134153
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 ( ) => {
136155 const stepper = await loader . getHarness ( MatStepperHarness . with ( { selector : '#one-stepper' } ) ) ;
137156 const steps = await stepper . getSteps ( ) ;
138157
139- expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
158+ expect ( await parallel ( ( ) => steps . map ( step => step . isExpanded ( ) ) ) ) . toEqual ( [
140159 true ,
141160 false ,
142161 false ,
143162 false ,
144163 ] ) ;
145164 } ) ;
146165
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' } ) ) ;
149168 const steps = await stepper . getSteps ( ) ;
150169
151170 expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
152171 true ,
153172 false ,
154173 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 ,
155185 false ,
156186 ] ) ;
157187
158188 await steps [ 2 ] . select ( ) ;
159189
160- expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
190+ expect ( await parallel ( ( ) => steps . map ( step => step . isExpanded ( ) ) ) ) . toEqual ( [
161191 false ,
162192 false ,
163193 true ,
164194 false ,
165195 ] ) ;
166196 } ) ;
167197
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+
168217 it ( 'should get whether a step is optional' , async ( ) => {
169218 const stepper = await loader . getHarness ( MatStepperHarness . with ( { selector : '#two-stepper' } ) ) ;
170219 const steps = await stepper . getSteps ( ) ;
@@ -183,15 +232,15 @@ describe('MatStepperHarness', () => {
183232 expect ( await previousButton . getText ( ) ) . toBe ( 'Previous' ) ;
184233 } ) ;
185234
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 ( ) => {
187236 const stepper = await loader . getHarness ( MatStepperHarness . with ( { selector : '#one-stepper' } ) ) ;
188237 const steps = await stepper . getSteps ( ) ;
189238 const secondStep = steps [ 1 ] ;
190239 const nextButton = await secondStep . getHarness ( MatStepperNextHarness ) ;
191240
192241 await secondStep . select ( ) ;
193242
194- expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
243+ expect ( await parallel ( ( ) => steps . map ( step => step . isExpanded ( ) ) ) ) . toEqual ( [
195244 false ,
196245 true ,
197246 false ,
@@ -200,23 +249,46 @@ describe('MatStepperHarness', () => {
200249
201250 await nextButton . click ( ) ;
202251
203- expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
252+ expect ( await parallel ( ( ) => steps . map ( step => step . isExpanded ( ) ) ) ) . toEqual ( [
204253 false ,
205254 false ,
206255 true ,
207256 false ,
208257 ] ) ;
209258 } ) ;
210259
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 ( ) => {
212284 const stepper = await loader . getHarness ( MatStepperHarness . with ( { selector : '#one-stepper' } ) ) ;
213285 const steps = await stepper . getSteps ( ) ;
214286 const secondStep = steps [ 1 ] ;
215287 const previousButton = await secondStep . getHarness ( MatStepperPreviousHarness ) ;
216288
217289 await secondStep . select ( ) ;
218290
219- expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
291+ expect ( await parallel ( ( ) => steps . map ( step => step . isExpanded ( ) ) ) ) . toEqual ( [
220292 false ,
221293 true ,
222294 false ,
@@ -225,9 +297,32 @@ describe('MatStepperHarness', () => {
225297
226298 await previousButton . click ( ) ;
227299
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+
228316 expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
317+ false ,
229318 true ,
230319 false ,
320+ ] ) ;
321+
322+ await previousButton . click ( ) ;
323+
324+ expect ( await parallel ( ( ) => steps . map ( step => step . isSelected ( ) ) ) ) . toEqual ( [
325+ true ,
231326 false ,
232327 false ,
233328 ] ) ;
@@ -279,12 +374,16 @@ describe('MatStepperHarness', () => {
279374 <mat-stepper id="two-stepper">
280375 <mat-step>
281376 <ng-template matStepLabel>One</ng-template>
377+ <button matStepperNext>Next</button>
282378 </mat-step>
283379 <mat-step optional>
284380 <ng-template matStepLabel>Two</ng-template>
381+ <button matStepperPrevious>Previous</button>
382+ <button matStepperNext>Next</button>
285383 </mat-step>
286384 <mat-step optional>
287385 <ng-template matStepLabel>Three</ng-template>
386+ <button matStepperPrevious>Previous</button>
288387 </mat-step>
289388 </mat-stepper>
290389
0 commit comments