+ expect(worker.opts).toStrictEqual({
+ killBehavior: KillBehaviors.SOFT,
+ maxInactiveTime: 60000,
+ killHandler: EMPTY_FUNCTION
+ })
+ })
+
+ it('Verify that worker options are checked at worker creation', () => {
+ expect(() => new ClusterWorker(() => {}, '')).toThrowError(
+ new TypeError('opts worker options parameter is not a plain object')
+ )
+ expect(
+ () => new ClusterWorker(() => {}, { killBehavior: '' })
+ ).toThrowError(new TypeError("killBehavior option '' is not valid"))
+ expect(() => new ClusterWorker(() => {}, { killBehavior: 0 })).toThrowError(
+ new TypeError("killBehavior option '0' is not valid")
+ )
+ expect(
+ () => new ThreadWorker(() => {}, { maxInactiveTime: '' })
+ ).toThrowError(new TypeError('maxInactiveTime option is not an integer'))
+ expect(
+ () => new ThreadWorker(() => {}, { maxInactiveTime: 0.5 })
+ ).toThrowError(new TypeError('maxInactiveTime option is not an integer'))
+ expect(
+ () => new ThreadWorker(() => {}, { maxInactiveTime: 0 })
+ ).toThrowError(
+ new TypeError(
+ 'maxInactiveTime option is not a positive integer greater or equal than 5'
+ )
+ )
+ expect(
+ () => new ThreadWorker(() => {}, { maxInactiveTime: 4 })
+ ).toThrowError(
+ new TypeError(
+ 'maxInactiveTime option is not a positive integer greater or equal than 5'
+ )
+ )
+ expect(() => new ThreadWorker(() => {}, { killHandler: '' })).toThrowError(
+ new TypeError('killHandler option is not a function')
+ )
+ 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')
+ )