X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fpools%2Fabstract%2Fabstract-pool.test.js;h=a2170491243313c13c65c36f8222eb5324e19eb9;hb=e843b9042b77e0e4e17c193820a3e05ffc92cffe;hp=03a5db7eac5eef8ef5464907892bb27aecbb0442;hpb=7c0ba92006a5c188738ffc5ff642c51f172df3d6;p=poolifier.git diff --git a/tests/pools/abstract/abstract-pool.test.js b/tests/pools/abstract/abstract-pool.test.js index 03a5db7e..a2170491 100644 --- a/tests/pools/abstract/abstract-pool.test.js +++ b/tests/pools/abstract/abstract-pool.test.js @@ -1,5 +1,9 @@ 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 @@ -56,11 +60,14 @@ describe('Abstract pool test suite', () => { }) 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 ) }) @@ -99,16 +106,23 @@ describe('Abstract pool test suite', () => { ) 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() })