test: verify worker properties value
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 4 Apr 2024 08:53:46 +0000 (10:53 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 4 Apr 2024 08:53:46 +0000 (10:53 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
tests/worker/cluster-worker.test.mjs
tests/worker/thread-worker.test.mjs

index 3392d96cd1502ccdd90fd1f72a21381570d4976e..228a969a574473c1ab78fa5e6c502baa8a1b9871 100644 (file)
@@ -9,6 +9,14 @@ describe('Cluster worker test suite', () => {
     restore()
   })
 
+  it('Verify worker properties value after initialization', () => {
+    const worker = new ClusterWorker(() => {})
+    expect(worker.isMain).toBe(true)
+    expect(worker.mainWorker).toBe(undefined)
+    expect(worker.taskFunctions).toBeInstanceOf(Map)
+    expect(worker.taskFunctions.size).toBe(2)
+  })
+
   it('Verify that sync kill handler is called when worker is killed', () => {
     const worker = new ClusterWorker(() => {}, {
       killHandler: stub().returns()
index e4a408d5246b600e08bed68c3979afb0e625e021..6d694ec6464c412d1d3860d246438689abb44e47 100644 (file)
@@ -9,6 +9,14 @@ describe('Thread worker test suite', () => {
     restore()
   })
 
+  it('Verify worker properties value after initialization', () => {
+    const worker = new ThreadWorker(() => {})
+    expect(worker.isMain).toBe(true)
+    expect(worker.mainWorker).toBe(null)
+    expect(worker.taskFunctions).toBeInstanceOf(Map)
+    expect(worker.taskFunctions.size).toBe(2)
+  })
+
   it('Verify that sync kill handler is called when worker is killed', () => {
     const worker = new ThreadWorker(() => {}, {
       killHandler: stub().returns()