repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
build(deps-dev): bump @types/node
[poolifier.git]
/
tests
/
worker
/
thread-worker.test.js
diff --git
a/tests/worker/thread-worker.test.js
b/tests/worker/thread-worker.test.js
index 624e395c04f80cb752adc73f8e95d84b19300dab..495e10b13b92e2ff663ff1de551b65028a8a3841 100644
(file)
--- a/
tests/worker/thread-worker.test.js
+++ b/
tests/worker/thread-worker.test.js
@@
-3,21
+3,25
@@
const { ThreadWorker } = require('../../lib')
describe('Thread worker test suite', () => {
let numberOfMessagesPosted = 0
describe('Thread worker test suite', () => {
let numberOfMessagesPosted = 0
- const postMessage =
function ()
{
+ const postMessage =
() =>
{
++numberOfMessagesPosted
}
class SpyWorker extends ThreadWorker {
++numberOfMessagesPosted
}
class SpyWorker extends ThreadWorker {
- getMainWorker () {
- return { postMessage }
+ constructor (fn) {
+ super(fn)
+ this.port = { postMessage }
}
}
}
}
- it('Verify worker has default maxInactiveTime', () => {
+ it('Verify that handleError() method is working properly', () => {
+ const error = new Error('Error as an error')
const worker = new ThreadWorker(() => {})
const worker = new ThreadWorker(() => {})
- expect(worker.opts.maxInactiveTime).toStrictEqual(60000)
+ expect(worker.handleError(error)).toStrictEqual(error)
+ const errorMessage = 'Error as a string'
+ expect(worker.handleError(errorMessage)).toStrictEqual(errorMessage)
})
})
- it('Verify worker invoke
the getMainWorker and postMessage methods
', () => {
+ it('Verify worker invoke
s the postMessage() method on port property
', () => {
const worker = new SpyWorker(() => {})
worker.sendToMainWorker({ ok: 1 })
expect(numberOfMessagesPosted).toBe(1)
const worker = new SpyWorker(() => {})
worker.sendToMainWorker({ ok: 1 })
expect(numberOfMessagesPosted).toBe(1)