Skip to content

Commit d59ed69

Browse files
committed
test: add isWebWorker() helper test
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
1 parent ca9b88c commit d59ed69

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/utils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,12 @@ export const once = <T, A extends any[], R>(
280280
}
281281
}
282282

283+
/**
284+
* Returns whether the current environment is a web worker or not.
285+
*
286+
* @returns `true` if the current environment is a web worker, `false` otherwise.
287+
* @internal
288+
*/
283289
export const isWebWorker = () => {
284290
return (
285291
typeof WorkerGlobalScope !== 'undefined' &&

tests/utils.test.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
isAsyncFunction,
1919
isKillBehavior,
2020
isPlainObject,
21+
isWebWorker,
2122
max,
2223
median,
2324
min,
@@ -273,4 +274,8 @@ Deno.test('Utils test suite', async (t) => {
273274
expect(called).toBe(1)
274275
expect(result3).toBe(1)
275276
})
277+
278+
await t.step('Verify isWebWorker()', () => {
279+
expect(isWebWorker()).toBe(false)
280+
})
276281
})

0 commit comments

Comments
 (0)