From d10fe4b2fb99a96c19507d5965824a810b46d26e Mon Sep 17 00:00:00 2001 From: Martin Boonk Date: Mon, 13 May 2024 18:40:52 +0200 Subject: [PATCH] runapptests - Allow resetting the recorded calls --- bin/runapptests.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/runapptests.js b/bin/runapptests.js index 5eefa4905..4ac9cacf3 100755 --- a/bin/runapptests.js +++ b/bin/runapptests.js @@ -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":"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", "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); }); 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": p = p.then(() => { state.ok &= assertCall(step);