)
})
- it('Verify dynamic pool sizing', () => {
+ it('Verify that dynamic pool sizing is checked', () => {
expect(
() =>
new DynamicThreadPool(2, 1, './tests/worker-files/thread/testWorker.js')
const { expect } = require('expect')
const { FixedClusterPool, PoolEvents } = require('../../../lib')
const { WorkerFunctions } = require('../../test-types')
-const { waitWorkerEvents } = require('../../test-utils')
+const { waitPoolEvents, waitWorkerEvents } = require('../../test-utils')
-describe('Fixed cluster pool test suite', () => {
+describe('Fixed cluster pool test suite', async () => {
const numberOfWorkers = 6
const pool = new FixedClusterPool(
numberOfWorkers,
errorHandler: e => console.error(e)
}
)
+ let poolReady = 0
+ pool.emitter.on(PoolEvents.ready, () => ++poolReady)
+ await waitPoolEvents(pool, PoolEvents.ready, 1)
const queuePool = new FixedClusterPool(
numberOfWorkers,
'./tests/worker-files/cluster/testWorker.js',
expect(result).toStrictEqual({ ok: 1 })
})
+ it("Verify that 'ready' event is emitted", async () => {
+ expect(poolReady).toBe(1)
+ })
+
it("Verify that 'busy' event is emitted", async () => {
let poolBusy = 0
pool.emitter.on(PoolEvents.busy, () => ++poolBusy)
const { expect } = require('expect')
const { FixedThreadPool, PoolEvents } = require('../../../lib')
const { WorkerFunctions } = require('../../test-types')
-const { waitWorkerEvents } = require('../../test-utils')
+const { waitPoolEvents, waitWorkerEvents } = require('../../test-utils')
-describe('Fixed thread pool test suite', () => {
+describe('Fixed thread pool test suite', async () => {
const numberOfThreads = 6
const pool = new FixedThreadPool(
numberOfThreads,
errorHandler: e => console.error(e)
}
)
+ let poolReady = 0
+ pool.emitter.on(PoolEvents.ready, () => ++poolReady)
+ await waitPoolEvents(pool, PoolEvents.ready, 1)
const queuePool = new FixedThreadPool(
numberOfThreads,
'./tests/worker-files/thread/testWorker.js',
expect(result).toStrictEqual({ ok: 1 })
})
+ it("Verify that 'ready' event is emitted", async () => {
+ expect(poolReady).toBe(1)
+ })
+
it("Verify that 'busy' event is emitted", async () => {
let poolBusy = 0
pool.emitter.on(PoolEvents.busy, () => ++poolBusy)