const expect = require('expect')
-const { FixedClusterPool, FixedThreadPool } = require('../../../lib/index')
+const {
+ FixedClusterPool,
+ FixedThreadPool,
+ WorkerChoiceStrategies
+} = require('../../../lib/index')
const expectedError = new Error('Worker could not be found in tasks map')
const numberOfWorkers = 1
})
it('Verify that filePath is checked', () => {
+ const expectedError = new Error(
+ 'Please specify a file with a worker implementation'
+ )
expect(() => new FixedThreadPool(numberOfWorkers)).toThrowError(
- new Error('Please specify a file with a worker implementation')
+ expectedError
)
expect(() => new FixedThreadPool(numberOfWorkers, '')).toThrowError(
- new Error('Please specify a file with a worker implementation')
+ expectedError
)
})
)
expect(pool.opts.enableEvents).toEqual(true)
expect(pool.emitter).toBeDefined()
+ expect(pool.opts.workerChoiceStrategy).toBe(
+ WorkerChoiceStrategies.ROUND_ROBIN
+ )
pool.destroy()
pool = new FixedThreadPool(
numberOfWorkers,
'./tests/worker-files/thread/testWorker.js',
{
+ workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED,
enableEvents: false
}
)
expect(pool.opts.enableEvents).toEqual(false)
expect(pool.emitter).toBeUndefined()
+ expect(pool.opts.workerChoiceStrategy).toBe(
+ WorkerChoiceStrategies.LESS_RECENTLY_USED
+ )
pool.destroy()
})