const { expect } = require('expect')
-const { FixedThreadPool } = require('../../../lib/index')
+const { FixedThreadPool, PoolEvents } = require('../../../lib/index')
const { WorkerFunctions } = require('../../test-types')
const TestUtils = require('../../test-utils')
expect(result).toBe(false)
})
- it('Verify that busy event is emitted', async () => {
+ it("Verify that 'busy' event is emitted", async () => {
let poolBusy = 0
- pool.emitter.on('busy', () => poolBusy++)
+ pool.emitter.on(PoolEvents.busy, () => ++poolBusy)
for (let i = 0; i < numberOfThreads * 2; i++) {
pool.execute()
}
it('Verify that async function is working properly', async () => {
const data = { f: 10 }
- const startTime = Date.now()
+ const startTime = performance.now()
const result = await asyncPool.execute(data)
- const usedTime = Date.now() - startTime
+ const usedTime = performance.now() - startTime
expect(result).toStrictEqual(data)
expect(usedTime).toBeGreaterThanOrEqual(2000)
})