Skip to content

Commit 6aed32c

Browse files
lucamaraschicjihrig
authored andcommitted
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: #11886 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 1ff6796 commit 6aed32c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
require('../common');
3+
const assert = require('assert');
4+
const fs = require('fs');
5+
6+
[undefined, null, []].forEach((input) => {
7+
assert.throws(() => fs._toUnixTimestamp(input),
8+
new RegExp('^Error: Cannot parse time: ' + input + '$'));
9+
});
10+
11+
assert.throws(() => fs._toUnixTimestamp({}),
12+
/^Error: Cannot parse time: \[object Object\]$/);
13+
14+
[1, '1', Date.now(), -1, '-1', Infinity].forEach((input) => {
15+
assert.doesNotThrow(() => fs._toUnixTimestamp(input));
16+
});

0 commit comments

Comments
 (0)