runapptests - Allow resetting the recorded calls

pull/3413/head
Martin Boonk 2024-05-13 18:40:52 +02:00
parent 107727ce6b
commit d10fe4b2fb
1 changed files with 8 additions and 1 deletions

View File

@ -57,7 +57,9 @@ 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":"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":"assertCall", "id": "testfunc", "count": 0 , "text": "Asserts if a wrapped function has been called the expected number of times"}
] ]
}] }]
} }
@ -276,6 +278,11 @@ function runStep(step, subtest, test, state){
state.ok &= assertArray(step); state.ok &= assertArray(step);
}); });
break; break;
case "resetCall":
console.log(`> RESET CALL ${step.id}`);
emu.tx(`global.APPTESTS.funcCalls.${step.id} = 0;\n`);
emu.tx(`global.APPTESTS.funcArgs.${step.id} = undefined;\n`);
break;
case "assertCall": case "assertCall":
p = p.then(() => { p = p.then(() => {
state.ok &= assertCall(step); state.ok &= assertCall(step);