mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-25 19:08:04 +01:00
Rename files
This commit is contained in:
35
ts/test-node/util/sleep_test.std.ts
Normal file
35
ts/test-node/util/sleep_test.std.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright 2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { assert } from 'chai';
|
||||
import { useFakeTimers } from 'sinon';
|
||||
|
||||
import { sleep } from '../../util/sleep.std.js';
|
||||
|
||||
describe('sleep', () => {
|
||||
beforeEach(function (this: Mocha.Context) {
|
||||
// This isn't a hook.
|
||||
this.clock = useFakeTimers();
|
||||
});
|
||||
|
||||
afterEach(function (this: Mocha.Context) {
|
||||
this.clock.restore();
|
||||
});
|
||||
|
||||
it('returns a promise that resolves after the specified number of milliseconds', async function (this: Mocha.Context) {
|
||||
let isDone = false;
|
||||
|
||||
void (async () => {
|
||||
await sleep(123);
|
||||
isDone = true;
|
||||
})();
|
||||
|
||||
assert.isFalse(isDone);
|
||||
|
||||
await this.clock.tickAsync(100);
|
||||
assert.isFalse(isDone);
|
||||
|
||||
await this.clock.tickAsync(25);
|
||||
assert.isTrue(isDone);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user