const expect = require('expect')
const { FixedThreadPool } = require('../../../lib/index')
-const numThreads = 10
+const numberOfThreads = 10
const maxTasks = 400
const pool = new FixedThreadPool(
- numThreads,
+ numberOfThreads,
'./tests/worker/thread/testWorker.js',
{
- errorHandler: e => console.error(e),
- onlineHandler: () => console.log('worker is online')
+ errorHandler: e => console.error(e)
}
)
const emptyPool = new FixedThreadPool(1, './tests/worker/thread/emptyWorker.js')
describe('Fixed thread pool test suite ', () => {
it('Choose worker round robin test', async () => {
const results = new Set()
- for (let i = 0; i < numThreads; i++) {
+ for (let i = 0; i < numberOfThreads; i++) {
results.add(pool.chooseWorker().threadId)
}
- expect(results.size).toBe(numThreads)
+ expect(results.size).toBe(numberOfThreads)
})
it('Verify that the function is executed in a worker thread', async () => {
})
})
await pool.destroy()
- expect(closedThreads).toBe(numThreads)
+ expect(closedThreads).toBe(numberOfThreads)
})
it('Validations test', () => {