mirror of https://github.com/espruino/BangleApps
runapptests - Rename sleep to advanceTime and add documentation
parent
db14c39c94
commit
9814dd424c
|
@ -92,7 +92,7 @@
|
||||||
{"t":"assertCall", "id": "gpspower", "argAsserts": [ { "t": "assert", "arg": "0", "is": "equal", "to": 0 } ], "text": "internal GPS switched off"},
|
{"t":"assertCall", "id": "gpspower", "argAsserts": [ { "t": "assert", "arg": "0", "is": "equal", "to": 0 } ], "text": "internal GPS switched off"},
|
||||||
|
|
||||||
{"t":"resetCall", "id": "gpspower"},
|
{"t":"resetCall", "id": "gpspower"},
|
||||||
{"t":"sleep", "ms":"12000", "text": "wait for fallback"},
|
{"t":"advanceTime", "ms":"12000", "text": "wait for fallback"},
|
||||||
{"t":"assertCall", "id": "gpspower", "argAsserts": [ { "t": "assert", "arg": "0", "is": "equal", "to": 1 } ], "text": "internal GPS switched on caused by missing GB event"}
|
{"t":"assertCall", "id": "gpspower", "argAsserts": [ { "t": "assert", "arg": "0", "is": "equal", "to": 1 } ], "text": "internal GPS switched on caused by missing GB event"}
|
||||||
]
|
]
|
||||||
}]
|
}]
|
||||||
|
|
|
@ -57,10 +57,17 @@ const DEMOTEST = {
|
||||||
{"t":"assertArray", "js": "[1,2,3]", "is":"notEmpty", "text": "Evaluates the content of 'js' on the device and asserts if the result is an array with more than 0 entries"},
|
{"t":"assertArray", "js": "[1,2,3]", "is":"notEmpty", "text": "Evaluates the content of 'js' on the device and asserts if the result is an array with more than 0 entries"},
|
||||||
{"t":"cmd", "js": "global.testfunction(1)", "text": "Call function for the following asserts"},
|
{"t":"cmd", "js": "global.testfunction(1)", "text": "Call function for the following asserts"},
|
||||||
{"t":"assertCall", "id": "testfunc", "argAsserts": [ { "t": "assert", "arg": "0", "is": "equal", "to": 1 } ] , "text": "Asserts if a wrapped function has been called with the expected arguments"},
|
{"t":"assertCall", "id": "testfunc", "argAsserts": [ { "t": "assert", "arg": "0", "is": "equal", "to": 1 } ] , "text": "Asserts if a wrapped function has been called with the expected arguments"},
|
||||||
{"t":"assertCall", "id": "testfunc", "count": 1 , "text": "Asserts if a wrapped function has been called the expected number of times"},
|
|
||||||
{"t":"resetCall", "id": "testfunc", "text": "Reset the recorded calls"},
|
{"t":"resetCall", "id": "testfunc", "text": "Reset the recorded calls"},
|
||||||
{"t":"assertCall", "id": "testfunc", "count": 0 , "text": "Asserts if a wrapped function has been called the expected number of times"}
|
{"t":"assertCall", "id": "testfunc", "count": 0 , "text": "Asserts if a wrapped function has been called the expected number of times"}
|
||||||
]
|
]
|
||||||
|
}, {
|
||||||
|
"description": "Emulator time can advanced by a given amount. This currently works for timeouts,intervals and Date.now() calls",
|
||||||
|
"steps": [
|
||||||
|
{"t":"cmd", "js":"setTimeout(()=>{global.waited = true},60000)", "text": "Set a timeout for 60 seconds"},
|
||||||
|
{"t":"assert", "js":"global.waited", "is": "falsy", "text": "Timeout has not yet fired"},
|
||||||
|
{"t":"advanceTime", "ms":60000},
|
||||||
|
{"t":"assert", "js":"global.waited", "is": "true", "text": "Timeout has fired"}
|
||||||
|
]
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,9 +323,9 @@ function runStep(step, subtest, test, state){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "sleep" :
|
case "advanceTime" :
|
||||||
p = p.then(()=>{
|
p = p.then(()=>{
|
||||||
console.log("> SLEEP FOR", step.ms + "ms");
|
console.log("> ADVANCE TIME BY", step.ms + "ms");
|
||||||
if (!subtest.wrappedDateNow){
|
if (!subtest.wrappedDateNow){
|
||||||
emu.tx(`Date.now = (o)=>{return ()=>{
|
emu.tx(`Date.now = (o)=>{return ()=>{
|
||||||
return o() + global.APPTESTS.timeOffset;
|
return o() + global.APPTESTS.timeOffset;
|
||||||
|
|
Loading…
Reference in New Issue