build(deps-dev): apply updartes
[poolifier.git] / tests / pools / worker-node.test.mjs
index cfca3422b0f3ff727138608a65f7542dff63ba35..5633530f35d6fd0d06c1cae72af18405daabb997 100644 (file)
@@ -1,10 +1,13 @@
-import { MessageChannel } from 'node:worker_threads'
+import { Worker as ClusterWorker } from 'node:cluster'
+import { MessageChannel, Worker as ThreadWorker } from 'node:worker_threads'
+
 import { expect } from 'expect'
-import { WorkerNode } from '../../lib/pools/worker-node.js'
-import { WorkerTypes } from '../../lib/index.js'
-import { CircularArray } from '../../lib/circular-array.js'
-import { Deque } from '../../lib/deque.js'
-import { DEFAULT_TASK_NAME } from '../../lib/utils.js'
+
+import { CircularArray } from '../../lib/circular-array.cjs'
+import { Deque } from '../../lib/deque.cjs'
+import { WorkerTypes } from '../../lib/index.cjs'
+import { WorkerNode } from '../../lib/pools/worker-node.cjs'
+import { DEFAULT_TASK_NAME } from '../../lib/utils.cjs'
 
 describe('Worker node test suite', () => {
   const threadWorkerNode = new WorkerNode(
@@ -14,7 +17,7 @@ describe('Worker node test suite', () => {
   )
   const clusterWorkerNode = new WorkerNode(
     WorkerTypes.cluster,
-    './tests/worker-files/cluster/testWorker.js',
+    './tests/worker-files/cluster/testWorker.cjs',
     { tasksQueueBackPressureSize: 12 }
   )
 
@@ -118,11 +121,13 @@ describe('Worker node test suite', () => {
       )
     )
     expect(threadWorkerNode).toBeInstanceOf(WorkerNode)
+    expect(threadWorkerNode.worker).toBeInstanceOf(ThreadWorker)
     expect(threadWorkerNode.info).toStrictEqual({
       id: threadWorkerNode.worker.threadId,
       type: WorkerTypes.thread,
       dynamic: false,
-      ready: false
+      ready: false,
+      stealing: false
     })
     expect(threadWorkerNode.usage).toStrictEqual({
       tasks: {
@@ -160,11 +165,13 @@ describe('Worker node test suite', () => {
     expect(threadWorkerNode.taskFunctionsUsage).toBeInstanceOf(Map)
 
     expect(clusterWorkerNode).toBeInstanceOf(WorkerNode)
+    expect(clusterWorkerNode.worker).toBeInstanceOf(ClusterWorker)
     expect(clusterWorkerNode.info).toStrictEqual({
       id: clusterWorkerNode.worker.id,
       type: WorkerTypes.cluster,
       dynamic: false,
-      ready: false
+      ready: false,
+      stealing: false
     })
     expect(clusterWorkerNode.usage).toStrictEqual({
       tasks: {