node/test/parallel/test-timers-enroll-invalid-msecs.js
Mithun Sasidharan eae0c05697
test: replace assert.throws w/ common.expectsError
PR-URL: https://github.com/nodejs/node/pull/17498
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
2017-12-08 16:02:07 -05:00

37 lines
598 B
JavaScript

'use strict';
const common = require('../common');
const timers = require('timers');
[
{},
[],
'foo',
() => { },
Symbol('foo')
].forEach((val) => {
common.expectsError(
() => timers.enroll({}, val),
{
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError
}
);
});
[
-1,
Infinity,
NaN
].forEach((val) => {
common.expectsError(
() => timers.enroll({}, val),
{
code: 'ERR_VALUE_OUT_OF_RANGE',
type: RangeError,
message: 'The value of "msecs" must be a non-negative ' +
`finite number. Received "${val}"`
}
);
});