test: improve tranferable objects test
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 12 Aug 2023 12:05:59 +0000 (14:05 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 12 Aug 2023 12:05:59 +0000 (14:05 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
tests/pools/thread/fixed.test.js

index 849590a69f1bad0cbe8c903593002654b4dea70d..4fce0b9e14a18a9a9880a04ada512994d0793241 100644 (file)
@@ -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 () => {