test: improve AsyncLock test coverage
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 23 Aug 2024 20:17:15 +0000 (22:17 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 23 Aug 2024 20:17:15 +0000 (22:17 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
tests/utils/AsyncLock.test.ts

index 3ab1dcf5c83bd45647ad8d7926d9ebbc34f0e777..801cd023c5ee6c0ce1782c5a5ae5497aa38ca5a7 100644 (file)
@@ -1,4 +1,5 @@
 import { expect } from 'expect'
+import { randomInt } from 'node:crypto'
 import { describe, it } from 'node:test'
 
 import { AsyncLock, AsyncLockType } from '../../src/utils/AsyncLock.js'
@@ -28,7 +29,7 @@ await describe('AsyncLock test suite', async () => {
     let count = 0
     const asyncFn = async () => {
       await new Promise(resolve => {
-        setTimeout(resolve, 100)
+        setTimeout(resolve, randomInt(1, 100))
       })
       executed.push(++count)
     }