diff options
author | ttzztztz <ttzztztz@outlook.com> | 2021-02-18 06:01:55 +0300 |
---|---|---|
committer | Michaƫl Zasso <targos@protonmail.com> | 2021-02-28 16:41:30 +0300 |
commit | f2aa305348bfb51d18c6cb749b0dc9588b64ddb6 (patch) | |
tree | 1bab810212a0ae404a53b7ce0a6fc2bf3ffe008b /test | |
parent | 1408de7e24a9ccd66ad9938c68dd3a2cd058b205 (diff) |
test: fix incorrect timers-promisified case
PR-URL: https://github.com/nodejs/node/pull/37425
Fixes: https://github.com/nodejs/node/issues/37395
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-timers-promisified.js | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/test/parallel/test-timers-promisified.js b/test/parallel/test-timers-promisified.js index b802f655f08..04c3ff96149 100644 --- a/test/parallel/test-timers-promisified.js +++ b/test/parallel/test-timers-promisified.js @@ -392,18 +392,23 @@ process.on('multipleResolves', common.mustNotCall()); // Check that the timing is correct let pre = false; let post = false; - setPromiseTimeout(1).then(() => pre = true); - const iterable = setInterval(() => {}, 2); - const iterator = iterable[Symbol.asyncIterator](); - - iterator.next().then(common.mustCall(() => { - assert.ok(pre, 'interval ran too early'); - assert.ok(!post, 'interval ran too late'); - return iterator.next(); - })).then(common.mustCall(() => { - assert.ok(post, 'second interval ran too early'); - return iterator.return(); - })); - setPromiseTimeout(3).then(() => post = true); + const time_unit = 50; + Promise.all([ + setPromiseTimeout(1).then(() => pre = true), + new Promise((res) => { + const iterable = timerPromises.setInterval(time_unit * 2); + const iterator = iterable[Symbol.asyncIterator](); + + iterator.next().then(() => { + assert.ok(pre, 'interval ran too early'); + assert.ok(!post, 'interval ran too late'); + return iterator.next(); + }).then(() => { + assert.ok(post, 'second interval ran too early'); + return iterator.return(); + }).then(res); + }), + setPromiseTimeout(time_unit * 3).then(() => post = true) + ]).then(common.mustCall()); } |