From: Jérôme Benoit Date: Sat, 12 Aug 2023 12:05:59 +0000 (+0200) Subject: test: improve tranferable objects test X-Git-Tag: v2.6.24~6 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=f05314ff0ec1fce69d51345a4253ea22e5561747;p=poolifier.git test: improve tranferable objects test Signed-off-by: Jérôme Benoit --- diff --git a/tests/pools/thread/fixed.test.js b/tests/pools/thread/fixed.test.js index 849590a6..4fce0b9e 100644 --- a/tests/pools/thread/fixed.test.js +++ b/tests/pools/thread/fixed.test.js @@ -156,16 +156,29 @@ describe('Fixed thread pool test suite', () => { }) it('Verify that transferable objects are sent to the worker correctly', async () => { - const transferList = [new ArrayBuffer(16), new MessageChannel().port1] let error let result try { - result = await pool.execute(undefined, undefined, transferList) + result = await pool.execute(undefined, undefined, [ + new ArrayBuffer(16), + new MessageChannel().port1 + ]) } catch (e) { error = e } expect(result).toStrictEqual({ ok: 1 }) expect(error).toBeUndefined() + try { + result = await pool.execute(undefined, undefined, [ + new SharedArrayBuffer(16) + ]) + } catch (e) { + error = e + } + expect(result).toStrictEqual({ ok: 1 }) + expect(error).toStrictEqual( + new TypeError('Found invalid object in transferList') + ) }) it('Verify that error handling is working properly:sync', async () => {