From dd82bf6dc8ac011ff282a251109cb896f5600a97 Mon Sep 17 00:00:00 2001 From: apple502j <33279053+apple502j@users.noreply.github.com> Date: Wed, 25 Mar 2020 18:26:02 +0900 Subject: [PATCH] Added test --- test/unit/blocks_sensing.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/unit/blocks_sensing.js b/test/unit/blocks_sensing.js index 423b46e8d..ac7f41443 100644 --- a/test/unit/blocks_sensing.js +++ b/test/unit/blocks_sensing.js @@ -153,6 +153,23 @@ test('ask and answer with a visible target', t => { s.askAndWait({QUESTION: expectedQuestion}, util); }); +test('answer gets reset when runtime is disposed', t => { + const rt = new Runtime(); + const s = new Sensing(rt); + const util = {target: {visible: false}}; + const expectedAnswer = 'the answer'; + + rt.addListener('QUESTION', () => rt.emit('ANSWER', expectedAnswer)); + const promise = s.askAndWait({QUESTION: ''}, util); + + promise.then(() => t.strictEqual(s.getAnswer(), expectedAnswer)) + .then(() => rt.dispose()) + .then(() => { + t.strictEqual(s.getAnswer(), ''); + t.end(); + }); +}); + test('set drag mode', t => { const runtime = new Runtime(); runtime.requestTargetsUpdate = () => {}; // noop for testing