Merge dependabot/npm_and_yarn/examples/typescript/http-server-pool/fastify-cluster...
[poolifier.git] / tests / pools / abstract / worker-node.test.js
index df4e03fead8e71319bbab00178297d9e80ea9060..c57ce953fdf826be0811043cc292c340f47b5b8e 100644 (file)
@@ -1,5 +1,5 @@
-const { MessageChannel, Worker } = require('worker_threads')
-const cluster = require('cluster')
+const { MessageChannel, Worker } = require('node:worker_threads')
+const cluster = require('node:cluster')
 const { expect } = require('expect')
 const { WorkerNode } = require('../../../lib/pools/worker-node')
 const { WorkerTypes } = require('../../../lib')
@@ -29,6 +29,21 @@ describe('Worker node test suite', () => {
         'Cannot construct a worker node with a tasks queue back pressure size that is not an integer'
       )
     )
+    expect(() => new WorkerNode(threadWorker, 0.2)).toThrowError(
+      new TypeError(
+        'Cannot construct a worker node with a tasks queue back pressure size that is not an integer'
+      )
+    )
+    expect(() => new WorkerNode(threadWorker, 0)).toThrowError(
+      new RangeError(
+        'Cannot construct a worker node with a tasks queue back pressure size that is not a positive integer'
+      )
+    )
+    expect(() => new WorkerNode(threadWorker, -1)).toThrowError(
+      new RangeError(
+        'Cannot construct a worker node with a tasks queue back pressure size that is not a positive integer'
+      )
+    )
     expect(threadWorkerNode).toBeInstanceOf(WorkerNode)
     expect(threadWorkerNode.worker).toBe(threadWorker)
     expect(threadWorkerNode.info).toStrictEqual({