Skip to content

Commit

Permalink
test: add tests for unixtimestamp generation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
lucamaraschi authored and cjihrig committed Mar 20, 2017
1 parent 1ff6796 commit 6aed32c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/parallel/test-fs-timestamp-parsing-error.js
Original file line number Diff line number Diff line change
@@ -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));
});

0 comments on commit 6aed32c

Please sign in to comment.