summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/timers_test.ts44
1 files changed, 16 insertions, 28 deletions
diff --git a/js/timers_test.ts b/js/timers_test.ts
index 8d5245f11..78f6610c4 100644
--- a/js/timers_test.ts
+++ b/js/timers_test.ts
@@ -32,25 +32,21 @@ test(async function timeoutSuccess() {
});
test(async function timeoutArgs() {
+ const { promise, resolve } = deferred();
const arg = 1;
- await new Promise((resolve, reject) => {
- setTimeout(
- (a, b, c) => {
- try {
- assertEqual(a, arg);
- assertEqual(b, arg.toString());
- assertEqual(c, [arg]);
- resolve();
- } catch (e) {
- reject(e);
- }
- },
- 10,
- arg,
- arg.toString(),
- [arg]
- );
- });
+ setTimeout(
+ (a, b, c) => {
+ assertEqual(a, arg);
+ assertEqual(b, arg.toString());
+ assertEqual(c, [arg]);
+ resolve();
+ },
+ 10,
+ arg,
+ arg.toString(),
+ [arg]
+ );
+ await promise;
});
test(async function timeoutCancelSuccess() {
@@ -151,16 +147,8 @@ test(async function intervalOrdering() {
clearTimeout(timers[i]);
}
}
- await new Promise((resolve, reject) => {
- setTimeout(() => {
- try {
- assertEqual(timeouts, 1);
- resolve();
- } catch (e) {
- reject(e);
- }
- }, 100);
- });
+ await waitForMs(100);
+ assertEqual(timeouts, 1);
});
test(async function intervalCancelInvalidSilentFail() {