Properly integrate standard JS tools for JS and TS code
[poolifier.git] / tests / worker / abstract-worker.test.js
index c75227cc0bd8fcb8f0de0fe3f4b1b025e513245a..fbc9a06d26082b007d01572e95f02f610dc1f1a5 100644 (file)
@@ -5,16 +5,22 @@ describe('Abstract worker test suite', () => {
   class StubPoolWithIsMainWorker extends ThreadWorker {
     constructor (fn, opts) {
       super(fn, opts)
-      this.mainWorker = false
+      this.mainWorker = undefined
     }
   }
 
-  it('Verify that fn function is mandatory', () => {
+  it('Verify that fn parameter is mandatory', () => {
     expect(() => new ClusterWorker()).toThrowError(
       new Error('fn parameter is mandatory')
     )
   })
 
+  it('Verify that fn parameter is a function', () => {
+    expect(() => new ClusterWorker({})).toThrowError(
+      new TypeError('fn parameter is not a function')
+    )
+  })
+
   it('Verify worker options default values', () => {
     const worker = new ThreadWorker(() => {})
     expect(worker.opts.maxInactiveTime).toStrictEqual(60000)
@@ -36,7 +42,7 @@ describe('Abstract worker test suite', () => {
   it('Verify that handleError function is working properly', () => {
     const error = new Error('My error')
     const worker = new ThreadWorker(() => {})
-    expect(worker.handleError(error)).toBe(error)
+    expect(worker.handleError(error)).toStrictEqual(error)
   })
 
   it('Verify that get main worker throw error if main worker is not set', () => {