From 18ecc6c58fb5ba2e28b874b47980089351b5674f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 2 Oct 2023 19:13:51 +0200 Subject: [PATCH] test: cleanup worker error tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- tests/worker/abstract-worker.test.mjs | 9 --------- tests/worker/cluster-worker.test.mjs | 9 +++++++++ tests/worker/thread-worker.test.mjs | 1 + 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/worker/abstract-worker.test.mjs b/tests/worker/abstract-worker.test.mjs index 9058790b..11bf6927 100644 --- a/tests/worker/abstract-worker.test.mjs +++ b/tests/worker/abstract-worker.test.mjs @@ -200,15 +200,6 @@ describe('Abstract worker test suite', () => { expect(killHandlerStub.calledOnce).toBe(true) }) - it('Verify that handleError() method is working properly', () => { - const error = new Error('Error as an error') - const worker = new ClusterWorker(() => {}) - expect(worker.handleError(error)).not.toBeInstanceOf(Error) - expect(worker.handleError(error)).toStrictEqual(error.message) - const errorMessage = 'Error as a string' - expect(worker.handleError(errorMessage)).toStrictEqual(errorMessage) - }) - it('Verify that getMainWorker() throw error if main worker is not set', () => { expect(() => new StubWorkerWithMainWorker(() => {}).getMainWorker() diff --git a/tests/worker/cluster-worker.test.mjs b/tests/worker/cluster-worker.test.mjs index ea6a0481..f6a927aa 100644 --- a/tests/worker/cluster-worker.test.mjs +++ b/tests/worker/cluster-worker.test.mjs @@ -12,6 +12,15 @@ describe('Cluster worker test suite', () => { } } + it('Verify that handleError() method is working properly', () => { + const error = new Error('Error as an error') + const worker = new ClusterWorker(() => {}) + expect(worker.handleError(error)).not.toBeInstanceOf(Error) + expect(worker.handleError(error)).toStrictEqual(error.message) + const errorMessage = 'Error as a string' + expect(worker.handleError(errorMessage)).toStrictEqual(errorMessage) + }) + it('Verify worker invokes the getMainWorker() and send() methods', () => { const worker = new SpyWorker(() => {}) worker.sendToMainWorker({ ok: 1 }) diff --git a/tests/worker/thread-worker.test.mjs b/tests/worker/thread-worker.test.mjs index 8b6f9c79..4be262a2 100644 --- a/tests/worker/thread-worker.test.mjs +++ b/tests/worker/thread-worker.test.mjs @@ -16,6 +16,7 @@ describe('Thread worker test suite', () => { it('Verify that handleError() method is working properly', () => { const error = new Error('Error as an error') const worker = new ThreadWorker(() => {}) + expect(worker.handleError(error)).toBeInstanceOf(Error) expect(worker.handleError(error)).toStrictEqual(error) const errorMessage = 'Error as a string' expect(worker.handleError(errorMessage)).toStrictEqual(errorMessage) -- 2.34.1