0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-timers-active.js
Sebastiaan Deckers bb29405904
lib,src: fix consistent spacing inside braces
PR-URL: https://github.com/nodejs/node/pull/14162
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-07-21 15:13:47 -04:00

35 lines
870 B
JavaScript

'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 });
});