repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
docs: add changelog entries
[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 c08adffd9816a9c0f4bd78337b857a664fa4553f..495e10b13b92e2ff663ff1de551b65028a8a3841 100644
(file)
--- a/
tests/worker/thread-worker.test.js
+++ b/
tests/worker/thread-worker.test.js
@@
-3,20
+3,16
@@
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', () => {
- const worker = new ThreadWorker(() => {})
- expect(worker.opts.maxInactiveTime).toStrictEqual(60000)
- })
-
it('Verify that handleError() method is working properly', () => {
const error = new Error('Error as an error')
const worker = new ThreadWorker(() => {})
it('Verify that handleError() method is working properly', () => {
const error = new Error('Error as an error')
const worker = new ThreadWorker(() => {})
@@
-25,7
+21,7
@@
describe('Thread worker test suite', () => {
expect(worker.handleError(errorMessage)).toStrictEqual(errorMessage)
})
expect(worker.handleError(errorMessage)).toStrictEqual(errorMessage)
})
- it('Verify worker invokes the
getMainWorker() and postMessage() methods
', () => {
+ it('Verify worker invokes 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)