test: cleanup tests description
[poolifier.git] / tests / worker / abstract-worker.test.js
index fbc9a06d26082b007d01572e95f02f610dc1f1a5..b62ba9425e1289fb8afc6361edc32f2be2ca9531 100644 (file)
@@ -9,18 +9,6 @@ describe('Abstract worker test suite', () => {
     }
   }
 
-  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)
@@ -39,15 +27,37 @@ describe('Abstract worker test suite', () => {
     expect(worker.opts.async).toBe(true)
   })
 
-  it('Verify that handleError function is working properly', () => {
+  it('Verify that fn parameter is mandatory', () => {
+    expect(() => new ClusterWorker()).toThrowError('fn parameter is mandatory')
+  })
+
+  it('Verify that fn parameter is a function', () => {
+    expect(() => new ClusterWorker({})).toThrowError(
+      new TypeError('fn parameter is not a function')
+    )
+    expect(() => new ClusterWorker('')).toThrowError(
+      new TypeError('fn parameter is not a function')
+    )
+  })
+
+  it('Verify that async fn parameter without async option throw error', () => {
+    const fn = async () => {
+      return new Promise()
+    }
+    expect(() => new ClusterWorker(fn)).toThrowError(
+      'fn parameter is an async function, please set the async option to true'
+    )
+  })
+
+  it('Verify that handleError() method is working properly', () => {
     const error = new Error('My error')
     const worker = new ThreadWorker(() => {})
     expect(worker.handleError(error)).toStrictEqual(error)
   })
 
-  it('Verify that get main worker throw error if main worker is not set', () => {
+  it('Verify that getMainWorker() throw error if main worker is not set', () => {
     expect(() =>
       new StubPoolWithIsMainWorker(() => {}).getMainWorker()
-    ).toThrowError(new Error('Main worker was not set'))
+    ).toThrowError('Main worker was not set')
   })
 })