summaryrefslogtreecommitdiff
path: root/test/parallel/test-fs-timestamp-parsing-error.js
blob: 4456a86830f43f0dbd02d25da7a7198717a749e1 (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
'use strict';
const common = require('../common');
const fs = require('fs');

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

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

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