-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Expand file tree
/
Copy pathtest-graph.intervals.js
More file actions
35 lines (28 loc) · 755 Bytes
/
test-graph.intervals.js
File metadata and controls
35 lines (28 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';
const common = require('../common');
const initHooks = require('./init-hooks');
const verifyGraph = require('./verify-graph');
const TIMEOUT = 1;
const hooks = initHooks();
hooks.enable();
let count = 0;
const iv1 = setInterval(common.mustCall(onfirstInterval, 3), TIMEOUT);
let iv2;
function onfirstInterval() {
if (++count === 3) {
clearInterval(iv1);
iv2 = setInterval(common.mustCall(onsecondInterval, 1), TIMEOUT + 1);
}
}
function onsecondInterval() {
clearInterval(iv2);
}
process.on('exit', onexit);
function onexit() {
hooks.disable();
verifyGraph(
hooks,
[ { type: 'Timeout', id: 'timeout:1', triggerAsyncId: null },
{ type: 'Timeout', id: 'timeout:2', triggerAsyncId: 'timeout:1' }],
);
}