2017-03-16 23:58:16 +01:00
|
|
|
'use strict';
|
2017-08-26 07:46:47 -04:00
|
|
|
const common = require('../common');
|
2017-03-16 23:58:16 +01:00
|
|
|
const fs = require('fs');
|
2017-03-17 17:07:19 +01:00
|
|
|
const assert = require('assert');
|
2017-03-16 23:58:16 +01:00
|
|
|
|
2017-03-17 17:07:19 +01:00
|
|
|
[Infinity, -Infinity, NaN].forEach((input) => {
|
2017-08-26 07:46:47 -04:00
|
|
|
common.expectsError(
|
|
|
|
() => {
|
|
|
|
fs._toUnixTimestamp(input);
|
|
|
|
},
|
|
|
|
{
|
|
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
2017-12-11 03:56:41 -02:00
|
|
|
type: TypeError
|
2017-08-26 07:46:47 -04:00
|
|
|
});
|
2017-03-16 23:58:16 +01:00
|
|
|
});
|
|
|
|
|
2017-08-26 07:46:47 -04:00
|
|
|
common.expectsError(
|
|
|
|
() => {
|
|
|
|
fs._toUnixTimestamp({});
|
|
|
|
},
|
|
|
|
{
|
|
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
2017-12-11 03:56:41 -02:00
|
|
|
type: TypeError
|
2017-08-26 07:46:47 -04:00
|
|
|
});
|
2017-03-16 23:58:16 +01:00
|
|
|
|
2017-03-17 17:07:19 +01:00
|
|
|
const okInputs = [1, -1, '1', '-1', Date.now()];
|
|
|
|
okInputs.forEach((input) => {
|
2017-03-16 23:58:16 +01:00
|
|
|
assert.doesNotThrow(() => fs._toUnixTimestamp(input));
|
|
|
|
});
|