You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

34 lines
870 B

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