node/test/parallel/test-fs-timestamp-parsing-error.js
Ruben Bridgewater f26cabbe24
test: fix wrong error classes passed in as type
PR-URL: https://github.com/nodejs/node/pull/13686
Fixes: https://github.com/nodejs/node/issues/13682
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2018-01-06 04:04:28 +01:00

30 lines
583 B
JavaScript

'use strict';
const common = require('../common');
const fs = require('fs');
const assert = require('assert');
[Infinity, -Infinity, NaN].forEach((input) => {
common.expectsError(
() => {
fs._toUnixTimestamp(input);
},
{
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError
});
});
common.expectsError(
() => {
fs._toUnixTimestamp({});
},
{
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError
});
const okInputs = [1, -1, '1', '-1', Date.now()];
okInputs.forEach((input) => {
assert.doesNotThrow(() => fs._toUnixTimestamp(input));
});