test: add tests for unixtimestamp generation
This test checks for the different input types for the generation of UNIX timestamps in the fs module. PR-URL: https://github.com/nodejs/node/pull/11886 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
1ff6796083
commit
6aed32c579
16
test/parallel/test-fs-timestamp-parsing-error.js
Normal file
16
test/parallel/test-fs-timestamp-parsing-error.js
Normal file
@ -0,0 +1,16 @@
|
||||
'use strict';
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
|
||||
[undefined, null, []].forEach((input) => {
|
||||
assert.throws(() => fs._toUnixTimestamp(input),
|
||||
new RegExp('^Error: Cannot parse time: ' + input + '$'));
|
||||
});
|
||||
|
||||
assert.throws(() => fs._toUnixTimestamp({}),
|
||||
/^Error: Cannot parse time: \[object Object\]$/);
|
||||
|
||||
[1, '1', Date.now(), -1, '-1', Infinity].forEach((input) => {
|
||||
assert.doesNotThrow(() => fs._toUnixTimestamp(input));
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user