@@ -391,6 +391,47 @@ describe('Integration: StepManagerComponent', function() {
391
391
expect ( $hook ( 'second' ) ) . not . to . be . visible ;
392
392
expect ( $hook ( 'third' ) ) . not . to . be . visible ;
393
393
} ) ;
394
+
395
+ it ( 'can transition to the previous step' , function ( ) {
396
+ this . render ( hbs `
397
+ {{#step-manager as |w|}}
398
+ <button id='previous' {{action w.transition-to-previous}}>
399
+ Previous!
400
+ </button>
401
+ <button id='next' {{action w.transition-to-next}}>
402
+ Next!
403
+ </button>
404
+
405
+ {{#w.step name='first'}}
406
+ <div data-test={{hook 'first'}}></div>
407
+ {{/w.step}}
408
+
409
+ {{#w.step name='second'}}
410
+ <div data-test={{hook 'second'}}></div>
411
+ {{/w.step}}
412
+
413
+ {{#w.step name='third'}}
414
+ <div data-test={{hook 'third'}}></div>
415
+ {{/w.step}}
416
+ {{/step-manager}}
417
+ ` ) ;
418
+
419
+ expect ( $hook ( 'first' ) ) . to . be . visible ;
420
+ expect ( $hook ( 'second' ) ) . not . to . be . visible ;
421
+ expect ( $hook ( 'third' ) ) . not . to . be . visible ;
422
+
423
+ click ( '#next' ) ;
424
+
425
+ expect ( $hook ( 'first' ) ) . not . to . be . visible ;
426
+ expect ( $hook ( 'second' ) ) . to . be . visible ;
427
+ expect ( $hook ( 'third' ) ) . not . to . be . visible ;
428
+
429
+ click ( '#previous' ) ;
430
+
431
+ expect ( $hook ( 'first' ) ) . to . be . visible ;
432
+ expect ( $hook ( 'second' ) ) . not . to . be . visible ;
433
+ expect ( $hook ( 'third' ) ) . not . to . be . visible ;
434
+ } ) ;
394
435
} ) ;
395
436
396
437
describe ( 'providing a `did-transition` action' , function ( ) {
@@ -662,8 +703,16 @@ describe('Integration: StepManagerComponent', function() {
662
703
{{/step-manager}}
663
704
` ) ;
664
705
665
- expect ( $hook ( 'step' , { index : 0 } ) . text ( ) . trim ( ) ) . to . equal ( 'Active' ) ;
666
- expect ( $hook ( 'step' , { index : 1 } ) . text ( ) . trim ( ) ) . to . equal ( 'Inactive' ) ;
706
+ expect (
707
+ $hook ( 'step' , { index : 0 } )
708
+ . text ( )
709
+ . trim ( )
710
+ ) . to . equal ( 'Active' ) ;
711
+ expect (
712
+ $hook ( 'step' , { index : 1 } )
713
+ . text ( )
714
+ . trim ( )
715
+ ) . to . equal ( 'Inactive' ) ;
667
716
} ) ;
668
717
} ) ;
669
718
@@ -693,13 +742,21 @@ describe('Integration: StepManagerComponent', function() {
693
742
694
743
expect ( $hook ( 'step' , { name : 'foo' } ) ) . to . be . visible ;
695
744
expect ( $hook ( 'step' , { name : 'bar' } ) ) . not . to . be . visible ;
696
- expect ( $hook ( 'steps' ) . text ( ) . trim ( ) ) . to . equal ( 'foo' ) ;
745
+ expect (
746
+ $hook ( 'steps' )
747
+ . text ( )
748
+ . trim ( )
749
+ ) . to . equal ( 'foo' ) ;
697
750
698
751
click ( 'button' ) ;
699
752
700
753
expect ( $hook ( 'step' , { name : 'foo' } ) ) . not . to . be . visible ;
701
754
expect ( $hook ( 'step' , { name : 'bar' } ) ) . to . be . visible ;
702
- expect ( $hook ( 'steps' ) . text ( ) . trim ( ) ) . to . equal ( 'bar' ) ;
755
+ expect (
756
+ $hook ( 'steps' )
757
+ . text ( )
758
+ . trim ( )
759
+ ) . to . equal ( 'bar' ) ;
703
760
} ) ;
704
761
705
762
it ( 'allows for adding more steps after the initial render' , function ( ) {
@@ -735,15 +792,23 @@ describe('Integration: StepManagerComponent', function() {
735
792
expect ( $hook ( 'step' , { name : 'foo' } ) ) . not . to . be . visible ;
736
793
expect ( $hook ( 'step' , { name : 'bar' } ) ) . not . to . be . visible ;
737
794
expect ( $hook ( 'step' , { name : 'baz' } ) ) . to . be . visible ;
738
- expect ( $hook ( 'steps' ) . text ( ) . trim ( ) ) . to . equal ( 'baz' ) ;
795
+ expect (
796
+ $hook ( 'steps' )
797
+ . text ( )
798
+ . trim ( )
799
+ ) . to . equal ( 'baz' ) ;
739
800
740
801
// Check that the new step now points to the first one
741
802
click ( 'button' ) ;
742
803
743
804
expect ( $hook ( 'step' , { name : 'foo' } ) ) . to . be . visible ;
744
805
expect ( $hook ( 'step' , { name : 'bar' } ) ) . not . to . be . visible ;
745
806
expect ( $hook ( 'step' , { name : 'baz' } ) ) . not . to . be . visible ;
746
- expect ( $hook ( 'steps' ) . text ( ) . trim ( ) ) . to . equal ( 'foo' ) ;
807
+ expect (
808
+ $hook ( 'steps' )
809
+ . text ( )
810
+ . trim ( )
811
+ ) . to . equal ( 'foo' ) ;
747
812
} ) ;
748
813
} ) ;
749
814
} ) ;
0 commit comments