@@ -26,8 +26,8 @@ const level: TT.Level = {
2626}
2727
2828describe ( 'stepNext' , ( ) => {
29- it ( 'should LOAD_NEXT_STEP when there is another step and is complete ' , ( ) => {
30- const position = { stepId : '1.1 ' , levelId : '1' , complete : true }
29+ it ( 'should LOAD_NEXT_STEP when there is another step' , ( ) => {
30+ const position = { levelId : '1' , stepId : '1.2 ' , complete : false }
3131 const result = getStepNext ( position , level )
3232 expect ( result ) . toEqual ( {
3333 type : 'LOAD_NEXT_STEP' ,
@@ -36,25 +36,26 @@ describe('stepNext', () => {
3636 } ,
3737 } )
3838 } )
39- it ( 'should LOAD_NEXT_STEP to the same step if not complete ' , ( ) => {
40- const position = { stepId : '1.1 ' , levelId : '1' , complete : false }
39+ it ( 'should LOAD_NEXT_STEP when there is another step but no more ' , ( ) => {
40+ const position = { levelId : '1' , stepId : '1.3 ' , complete : false }
4141 const result = getStepNext ( position , level )
4242 expect ( result ) . toEqual ( {
4343 type : 'LOAD_NEXT_STEP' ,
4444 payload : {
45- step : level . steps [ 0 ] ,
45+ step : level . steps [ 2 ] ,
4646 } ,
4747 } )
4848 } )
49+
4950 it ( 'should LEVEL_COMPLETE when there are no steps' , ( ) => {
50- const position = { stepId : '1.3 ' , levelId : '1' , complete : true }
51- const result = getStepNext ( position , level )
51+ const position = { levelId : '1' , stepId : null , complete : false }
52+ const result = getStepNext ( position , { ... level , steps : [ ] } )
5253 expect ( result ) . toEqual ( {
5354 type : 'LEVEL_COMPLETE' ,
5455 } )
5556 } )
5657 it ( 'should LEVEL_COMPLETE when all steps are complete' , ( ) => {
57- const position = { stepId : '1.3 ' , levelId : '1' , complete : true }
58+ const position = { levelId : '1' , stepId : '1.3 ' , complete : true }
5859 const result = getStepNext ( position , { ...level , steps : [ ] } )
5960 expect ( result ) . toEqual ( {
6061 type : 'LEVEL_COMPLETE' ,
0 commit comments