0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00
nodejs/test/parallel/test-timers-unrefd-interval-still-fires.js
James M Snell 7192e913f7 test: improve multiple timers tests
PR-URL: https://github.com/nodejs/node/pull/14616
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2017-08-07 17:33:59 -07:00

25 lines
548 B
JavaScript

'use strict';
/*
* This test is a regression test for joyent/node#8900.
*/
const common = require('../common');
const TEST_DURATION = common.platformTimeout(1000);
let N = 3;
const keepOpen =
setTimeout(
common.mustNotCall('Test timed out. keepOpen was not canceled.'),
TEST_DURATION);
const timer = setInterval(common.mustCall(() => {
if (--N === 0) {
clearInterval(timer);
timer._onTimeout =
common.mustNotCall('Unrefd interal fired after being cleared');
clearTimeout(keepOpen);
}
}, N), 1);
timer.unref();