summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorLi Hao <hao.x.li@intel.com>2018-10-08 14:58:44 +0800
committerRyan Dahl <ry@tinyclouds.org>2018-10-11 13:21:25 -0400
commit951e5def9856ee15be52c153a1d2cb7dd73f0da8 (patch)
tree040ebd1416e90644d3a59edb4e960ac95eed2461 /js
parent900dd6fa42cf841e82c564ac684f254b548d7e9e (diff)
timers: align unit tests with others
Diffstat (limited to 'js')
-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() {