Ligth number of threads
[poolifier.git] / tests / util.test.js
1 const expect = require('expect')
2 const { generateID, randomWorker } = require('../lib/util')
3
4 describe('Utility Tests ', () => {
5 it('Generate an id', () => {
6 const res = generateID()
7 expect(res).toBeTruthy()
8 expect(typeof res).toBe('string')
9 })
10
11 it('Choose a random worker', () => {
12 const input = new Map()
13 input.set(1, 1)
14 input.set(2, 2)
15 input.set(3, 3)
16 const worker = randomWorker(input)
17 expect(worker).toBeTruthy()
18 expect(Array.from(input.keys()).includes(worker)).toBeTruthy()
19 })
20 })