Ligth number of threads
[poolifier.git] / tests / util.test.js
CommitLineData
973cde26 1const expect = require('expect')
506c2a14 2const { generateID, randomWorker } = require('../lib/util')
973cde26 3
506c2a14 4describe('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()
973cde26 19 })
973cde26 20})