test: add tests for utils helper
[poolifier.git] / tests / worker-files / thread / testWorker.js
CommitLineData
106744f7 1'use strict'
106744f7 2const { isMainThread } = require('worker_threads')
65d7a1c9 3const { ThreadWorker, KillBehaviors } = require('../../../lib')
cf597bc5 4const TestUtils = require('../../test-utils')
2d2e32c2 5const { WorkerFunctions } = require('../../test-types')
106744f7 6
7function test (data) {
6db75ad9
JB
8 data = data || {}
9 data.function = data.function || WorkerFunctions.jsonIntegerSerialization
70a4f5ea
JB
10 const result = TestUtils.executeWorkerFunction(data)
11 if (result == null) {
12 return isMainThread
13 }
14 return result
106744f7 15}
16
4c35177b 17module.exports = new ThreadWorker(test, {
18 maxInactiveTime: 500,
1a81f8af 19 killBehavior: KillBehaviors.HARD
4c35177b 20})