blob: ac79c6fc1e1ca080ba99a9c90fb912748b7b9ba6 (
plain)
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
|
'use strict';
require('../common');
const assert = require('assert');
const active = require('timers').active;
// active() should create timers for these
const legitTimers = [
{ _idleTimeout: 0 },
{ _idleTimeout: 1 },
];
legitTimers.forEach(function(legit) {
const savedTimeout = legit._idleTimeout;
active(legit);
// active() should mutate these objects
assert.strictEqual(legit._idleTimeout, savedTimeout);
assert(Number.isInteger(legit._idleStart));
assert(legit._idleNext);
assert(legit._idlePrev);
});
// active() should not create a timer for these
const bogusTimers = [
{ _idleTimeout: -1 },
{ _idleTimeout: undefined },
];
bogusTimers.forEach(function(bogus) {
const savedTimeout = bogus._idleTimeout;
active(bogus);
// active() should not mutate these objects
assert.deepStrictEqual(bogus, { _idleTimeout: savedTimeout });
});
|