test: add test for transferable objects in execute() for worker_threads
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 12 Aug 2023 09:45:13 +0000 (11:45 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 12 Aug 2023 09:45:13 +0000 (11:45 +0200)
pool

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
tests/pools/thread/fixed.test.js

index 080ebad6ec8fa19b682bff11ae0f6634802c393e..849590a69f1bad0cbe8c903593002654b4dea70d 100644 (file)
@@ -155,6 +155,19 @@ describe('Fixed thread pool test suite', () => {
     expect(result).toStrictEqual(data)
   })
 
+  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)
+    } catch (e) {
+      error = e
+    }
+    expect(result).toStrictEqual({ ok: 1 })
+    expect(error).toBeUndefined()
+  })
+
   it('Verify that error handling is working properly:sync', async () => {
     const data = { f: 10 }
     let taskError