@@ -1218,6 +1218,49 @@ describe('Core', () => {
1218
1218
)
1219
1219
} )
1220
1220
} )
1221
+
1222
+ describe ( 'jumping' , ( ) => {
1223
+ let demoElement
1224
+ beforeEach ( ( ) => {
1225
+ demoElement = document . createElement ( 'div' )
1226
+ demoElement . dataset . labjsSection = 'main'
1227
+ document . body . appendChild ( demoElement )
1228
+ } )
1229
+
1230
+ afterEach ( ( ) => {
1231
+ document . body . removeChild ( demoElement )
1232
+ } )
1233
+
1234
+ it ( 'can jump around' , async ( ) => {
1235
+ const a = new lab . html . Screen ( { content : 'a' , id : 'a' } )
1236
+ const b = new lab . html . Screen ( { content : 'b' , id : 'b' } )
1237
+ const c = new lab . html . Screen ( { content : 'c' , id : 'c' } )
1238
+ const d = new lab . html . Screen ( { content : 'd' , id : 'd' } )
1239
+
1240
+ const s_nested = new lab . flow . Sequence ( { content : [ a , b , c , d ] , id : 's_nested' } )
1241
+ const t = new lab . html . Screen ( { content : 't' , id : 't' } )
1242
+ const s = new lab . flow . Sequence ( { content : [ s_nested , t ] , el : demoElement , id : 's' } )
1243
+
1244
+ const jumpTo = async ( targetStack ) => {
1245
+ await s . internals . controller . jump ( 'jump' , { targetStack } )
1246
+ }
1247
+
1248
+ await s . run ( )
1249
+ assert . equal ( demoElement . innerText , 'a' )
1250
+
1251
+ await jumpTo ( [ 's_nested' , 'b' ] )
1252
+ assert . equal ( demoElement . innerText , 'b' )
1253
+
1254
+ await b . end ( )
1255
+ assert . equal ( demoElement . innerText , 'c' )
1256
+
1257
+ await jumpTo ( [ 't' ] )
1258
+ assert . equal ( demoElement . innerText , 't' )
1259
+
1260
+ await jumpTo ( [ 's_nested' , 'b' ] )
1261
+ assert . equal ( demoElement . innerText , 'b' )
1262
+ } )
1263
+ } )
1221
1264
} )
1222
1265
1223
1266
} )
0 commit comments