Merge pull request '[v8.0/forgejo] test(js): false negative in sleep test' (#4307) from bp-v8.0/forgejo-a0d9d8d into v8.0/forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4307
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
Earl Warren 2024-07-03 18:36:22 +00:00
commit 51363f383d

View file

@ -177,10 +177,6 @@ test('serializeXml', () => {
}); });
test('sleep', async () => { test('sleep', async () => {
// Test 500 ms sleep
await testSleep(500);
// Test 2000 ms sleep
await testSleep(2000); await testSleep(2000);
}); });
@ -189,5 +185,5 @@ async function testSleep(ms) {
await sleep(ms); await sleep(ms);
const endTime = Date.now(); // Record the end time const endTime = Date.now(); // Record the end time
const actualSleepTime = endTime - startTime; const actualSleepTime = endTime - startTime;
expect(Math.abs(actualSleepTime - ms) <= 15).toBeTruthy(); expect(actualSleepTime >= ms).toBeTruthy();
} }