Apply dependencies update
[poolifier.git] / tests / worker / thread-worker.test.js
CommitLineData
a61a0724 1const { expect } = require('expect')
fd027a65
S
2const { ThreadWorker } = require('../../lib')
3
e1ffb94f
JB
4describe('Thread worker test suite', () => {
5 let numberOfMessagesPosted = 0
6 const postMessage = function () {
7 numberOfMessagesPosted++
8 }
9 class SpyWorker extends ThreadWorker {
10 getMainWorker () {
11 return { postMessage }
12 }
74a2a194 13 }
74a2a194 14
fd027a65
S
15 it('Verify worker has default maxInactiveTime', () => {
16 const worker = new ThreadWorker(() => {})
e1ffb94f 17 expect(worker.opts.maxInactiveTime).toStrictEqual(60000)
fd027a65 18 })
74a2a194
APA
19
20 it('Verify worker invoke the getMainWorker and postMessage methods', () => {
21 const worker = new SpyWorker(() => {})
22 worker.sendToMainWorker({ ok: 1 })
23 expect(numberOfMessagesPosted).toBe(1)
24 })
fd027a65 25})