expect(() => new ThreadWorker(() => {}, { killHandler: 0 })).toThrowError(
new TypeError('killHandler option is not a function')
)
- expect(() => new ThreadWorker(() => {}, { async: true })).toThrowError(
- new TypeError('async option is deprecated')
- )
})
it('Verify that worker options are set at worker creation', () => {
it('Verify that async kill handler is called when worker is killed', () => {
const killHandlerStub = stub().returns()
const worker = new ClusterWorker(() => {}, {
- killHandler: async () => Promise.resolve(killHandlerStub())
+ killHandler: async () => await Promise.resolve(killHandlerStub())
})
worker.isMain = false
worker.handleKillMessage()