summaryrefslogtreecommitdiff
path: root/test/parallel/test-fs-timestamp-parsing-error.js
blob: 3680b5fece13c9355f4815bd02cdb7539ab2f210 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';
const common = require('../common');
const fs = require('fs');
const assert = require('assert');

[Infinity, -Infinity, NaN].forEach((input) => {
  common.expectsError(
    () => {
      fs._toUnixTimestamp(input);
    },
    {
      code: 'ERR_INVALID_ARG_TYPE',
      type: Error
    });
});

common.expectsError(
  () => {
    fs._toUnixTimestamp({});
  },
  {
    code: 'ERR_INVALID_ARG_TYPE',
    type: Error
  });

const okInputs = [1, -1, '1', '-1', Date.now()];
okInputs.forEach((input) => {
  assert.doesNotThrow(() => fs._toUnixTimestamp(input));
});