X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=tests%2Futils.test.mjs;h=6e97797e35bfc4228e750c3ddf519b625667da77;hb=80115618ce24038f504dc447dfb7c4fbd9c5d698;hp=b6551dbdeeac64f6ab60c74608692bbd42be90f6;hpb=f903b9c3bee3649a69e13c1259270fd9730979c7;p=poolifier.git diff --git a/tests/utils.test.mjs b/tests/utils.test.mjs index b6551dbd..6e97797e 100644 --- a/tests/utils.test.mjs +++ b/tests/utils.test.mjs @@ -1,11 +1,14 @@ -import os from 'node:os' import { randomInt } from 'node:crypto' +import os from 'node:os' + import { expect } from 'expect' + +import { KillBehaviors } from '../lib/index.cjs' import { - DEFAULT_TASK_NAME, - EMPTY_FUNCTION, availableParallelism, average, + DEFAULT_TASK_NAME, + EMPTY_FUNCTION, exponentialDelay, isAsyncFunction, isKillBehavior, @@ -18,7 +21,6 @@ import { secureRandom, sleep } from '../lib/utils.cjs' -import { KillBehaviors } from '../lib/index.cjs' describe('Utils test suite', () => { it('Verify DEFAULT_TASK_NAME value', () => { @@ -35,6 +37,7 @@ describe('Utils test suite', () => { expect(Number.isSafeInteger(parallelism)).toBe(true) let expectedParallelism = 1 try { + // eslint-disable-next-line n/no-unsupported-features/node-builtins expectedParallelism = os.availableParallelism() } catch { expectedParallelism = os.cpus().length @@ -148,7 +151,7 @@ describe('Utils test suite', () => { expect(isAsyncFunction([])).toBe(false) expect(isAsyncFunction(new Date())).toBe(false) // eslint-disable-next-line prefer-regex-literals - expect(isAsyncFunction(new RegExp('[a-z]', 'i'))).toBe(false) + expect(isAsyncFunction(/[a-z]/i)).toBe(false) expect(isAsyncFunction(new Error())).toBe(false) expect(isAsyncFunction(new Map())).toBe(false) expect(isAsyncFunction(new Set())).toBe(false) @@ -204,20 +207,20 @@ describe('Utils test suite', () => { }) it('Verify min() behavior', () => { - expect(min()).toBe(Infinity) + expect(min()).toBe(Number.POSITIVE_INFINITY) expect(min(1, 2)).toBe(1) expect(min(2, 1)).toBe(1) expect(min(1, 1)).toBe(1) }) it('Verify max() behavior', () => { - expect(max()).toBe(-Infinity) + expect(max()).toBe(Number.NEGATIVE_INFINITY) expect(max(1, 2)).toBe(2) expect(max(2, 1)).toBe(2) expect(max(1, 1)).toBe(1) }) - // it('Verify once()', () => { + // it('Verify once() behavior', () => { // let called = 0 // const fn = () => ++called // const onceFn = once(fn, this)