From: Jérôme Benoit Date: Mon, 3 Jul 2023 19:01:43 +0000 (+0200) Subject: test: add test for isAsyncFunction() helper X-Git-Tag: v2.6.7~5 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=78ac1a90f8ebbe32f3b94c10f37cefe39090e9a3;p=poolifier.git test: add test for isAsyncFunction() helper Signed-off-by: Jérôme Benoit --- diff --git a/tests/utils.test.js b/tests/utils.test.js index 7ad3a5c7..f220927e 100644 --- a/tests/utils.test.js +++ b/tests/utils.test.js @@ -1,6 +1,7 @@ const { expect } = require('expect') const { availableParallelism, + isAsyncFunction, isKillBehavior, isPlainObject, median, @@ -79,6 +80,49 @@ describe('Utils test suite', () => { expect(isKillBehavior(KillBehaviors.SOFT)).toBe(false) expect(isKillBehavior(KillBehaviors.HARD)).toBe(false) expect(isKillBehavior(KillBehaviors.HARD, null)).toBe(false) + expect(isKillBehavior(KillBehaviors.HARD, undefined)).toBe(false) expect(isKillBehavior(KillBehaviors.SOFT, 'unknown')).toBe(false) }) + + it('Verify isAsyncFunction() behavior', () => { + expect(isAsyncFunction(null)).toBe(false) + expect(isAsyncFunction(undefined)).toBe(false) + expect(isAsyncFunction(true)).toBe(false) + expect(isAsyncFunction(false)).toBe(false) + expect(isAsyncFunction(0)).toBe(false) + expect(isAsyncFunction('')).toBe(false) + expect(isAsyncFunction([])).toBe(false) + expect(isAsyncFunction(new Date())).toBe(false) + expect(isAsyncFunction(new RegExp())).toBe(false) + expect(isAsyncFunction(new Error())).toBe(false) + expect(isAsyncFunction(new Map())).toBe(false) + expect(isAsyncFunction(new Set())).toBe(false) + expect(isAsyncFunction(new WeakMap())).toBe(false) + expect(isAsyncFunction(new WeakSet())).toBe(false) + expect(isAsyncFunction(new Int8Array())).toBe(false) + expect(isAsyncFunction(new Uint8Array())).toBe(false) + expect(isAsyncFunction(new Uint8ClampedArray())).toBe(false) + expect(isAsyncFunction(new Int16Array())).toBe(false) + expect(isAsyncFunction(new Uint16Array())).toBe(false) + expect(isAsyncFunction(new Int32Array())).toBe(false) + expect(isAsyncFunction(new Uint32Array())).toBe(false) + expect(isAsyncFunction(new Float32Array())).toBe(false) + expect(isAsyncFunction(new Float64Array())).toBe(false) + expect(isAsyncFunction(new BigInt64Array())).toBe(false) + expect(isAsyncFunction(new BigUint64Array())).toBe(false) + expect(isAsyncFunction(new Promise(() => {}))).toBe(false) + expect(isAsyncFunction(new WeakRef({}))).toBe(false) + expect(isAsyncFunction(new FinalizationRegistry(() => {}))).toBe(false) + expect(isAsyncFunction(new ArrayBuffer())).toBe(false) + expect(isAsyncFunction(new SharedArrayBuffer())).toBe(false) + expect(isAsyncFunction(new DataView(new ArrayBuffer()))).toBe(false) + expect(isAsyncFunction({})).toBe(false) + expect(isAsyncFunction({ a: 1 })).toBe(false) + expect(isAsyncFunction(() => {})).toBe(false) + expect(isAsyncFunction(function () {})).toBe(false) + expect(isAsyncFunction(function named () {})).toBe(false) + expect(isAsyncFunction(async () => {})).toBe(true) + expect(isAsyncFunction(async function () {})).toBe(true) + expect(isAsyncFunction(async function named () {})).toBe(true) + }) })