Skip to content
Permalink
Browse files

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>
  • Loading branch information...
lucamaraschi authored and cjihrig committed Mar 16, 2017
1 parent 1ff6796 commit 6aed32c57986b90290459e155aca20b962cd3829
Showing with 16 additions and 0 deletions.
  1. +16 −0 test/parallel/test-fs-timestamp-parsing-error.js
@@ -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.
You can’t perform that action at this time.