@@ -50,7 +50,7 @@ describe('turn orders', () => {
5050
5151 test ( 'DEFAULT' , ( ) => {
5252 const flow = Flow ( {
53- phases : { A : { start : true } , B : { } } ,
53+ phases : { A : { start : true , next : 'B' } , B : { } } ,
5454 } ) ;
5555
5656 let state = { ctx : flow . ctx ( 2 ) } ;
@@ -62,7 +62,35 @@ describe('turn orders', () => {
6262 expect ( state . ctx . currentPlayer ) . toBe ( '1' ) ;
6363 state = flow . processGameEvent ( state , gameEvent ( 'endTurn' ) ) ;
6464 expect ( state . ctx . currentPlayer ) . toBe ( '0' ) ;
65+ state = flow . processGameEvent ( state , gameEvent ( 'endTurn' ) ) ;
66+ expect ( state . ctx . currentPlayer ) . toBe ( '1' ) ;
6567 expect ( state . ctx . phase ) . toBe ( 'A' ) ;
68+ state = flow . processGameEvent ( state , gameEvent ( 'endPhase' ) ) ;
69+ expect ( state . ctx . currentPlayer ) . toBe ( '1' ) ;
70+ expect ( state . ctx . phase ) . toBe ( 'B' ) ;
71+ } ) ;
72+
73+ test ( 'RESET' , ( ) => {
74+ const flow = Flow ( {
75+ turn : { order : TurnOrder . RESET } ,
76+ phases : { A : { start : true , next : 'B' } , B : { } } ,
77+ } ) ;
78+
79+ let state = { ctx : flow . ctx ( 2 ) } ;
80+ state = flow . init ( state ) ;
81+ expect ( state . ctx . currentPlayer ) . toBe ( '0' ) ;
82+ expect ( state . ctx ) . not . toHaveUndefinedProperties ( ) ;
83+
84+ state = flow . processGameEvent ( state , gameEvent ( 'endTurn' ) ) ;
85+ expect ( state . ctx . currentPlayer ) . toBe ( '1' ) ;
86+ state = flow . processGameEvent ( state , gameEvent ( 'endTurn' ) ) ;
87+ expect ( state . ctx . currentPlayer ) . toBe ( '0' ) ;
88+ state = flow . processGameEvent ( state , gameEvent ( 'endTurn' ) ) ;
89+ expect ( state . ctx . currentPlayer ) . toBe ( '1' ) ;
90+ expect ( state . ctx . phase ) . toBe ( 'A' ) ;
91+ state = flow . processGameEvent ( state , gameEvent ( 'endPhase' ) ) ;
92+ expect ( state . ctx . currentPlayer ) . toBe ( '0' ) ;
93+ expect ( state . ctx . phase ) . toBe ( 'B' ) ;
6694 } ) ;
6795
6896 test ( 'ONCE' , ( ) => {
0 commit comments