@@ -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 }
3131const result = getStepNext ( position , level )
3232expect ( result ) . toEqual ( {
3333type :'LOAD_NEXT_STEP' ,
@@ -36,25 +36,26 @@ describe('stepNext', () => {
3636} ,
3737} )
3838} )
39- it ( 'should LOAD_NEXT_STEPto the same stepif not complete ' , ( ) => {
40- const position = { stepId :'1.1 ' , levelId :'1' , complete :false }
39+ it ( 'should LOAD_NEXT_STEPwhen there is another stepbut no more ' , ( ) => {
40+ const position = { levelId :'1' , stepId :'1.3 ' , complete :false }
4141const result = getStepNext ( position , level )
4242expect ( result ) . toEqual ( {
4343type :'LOAD_NEXT_STEP' ,
4444payload :{
45- step :level . steps [ 0 ] ,
45+ step :level . steps [ 2 ] ,
4646} ,
4747} )
4848} )
49+
4950it ( '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 : [ ] } )
5253expect ( result ) . toEqual ( {
5354type :'LEVEL_COMPLETE' ,
5455} )
5556} )
5657it ( '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 }
5859const result = getStepNext ( position , { ...level , steps :[ ] } )
5960expect ( result ) . toEqual ( {
6061type :'LEVEL_COMPLETE' ,