X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fsrc%2Fworker.js;h=5c97c0b24dd33de7dabdceb02ed298320d971188;hb=cab7ebc31583981d0c235039afdfc9d63e730f02;hp=32bd0656665bd854933240eb5323a440e1e438c5;hpb=c4d2acfc78cc8b67649c2eaa60a8c6c34c3e6675;p=websub-hub diff --git a/test/src/worker.js b/test/src/worker.js index 32bd065..5c97c0b 100644 --- a/test/src/worker.js +++ b/test/src/worker.js @@ -204,6 +204,18 @@ describe('Worker', function () { assert.strictEqual(worker._getWork.callCount, 0); assert.strictEqual(worker._recurr.callCount, 1); }); + it('covers double invocation', async function () { + const snooze = async (ms) => new Promise((resolve) => setTimeout(resolve, ms)); + + this.slow(300); + worker.inFlight = [ + Worker.watchedPromise(snooze(100)), + ]; + + await Promise.all([worker.process(), worker.process()]); + assert.strictEqual(worker._getWork.callCount, 2); + assert.strictEqual(worker._recurr.callCount, 1); + }); }); // process }); // Worker