1'use strict';
2
3const common = require('../common');
4const assert = require('assert');
5const fs = require('fs');
6
7[false, 1, [], {}, null, undefined].forEach((input) => {
8  const type = 'of type string or an instance of Buffer or URL.' +
9               common.invalidArgTypeHelper(input);
10  assert.throws(
11    () => fs.rename(input, 'does-not-exist', common.mustNotCall()),
12    {
13      code: 'ERR_INVALID_ARG_TYPE',
14      name: 'TypeError',
15      message: `The "oldPath" argument must be ${type}`
16    }
17  );
18  assert.throws(
19    () => fs.rename('does-not-exist', input, common.mustNotCall()),
20    {
21      code: 'ERR_INVALID_ARG_TYPE',
22      name: 'TypeError',
23      message: `The "newPath" argument must be ${type}`
24    }
25  );
26  assert.throws(
27    () => fs.renameSync(input, 'does-not-exist'),
28    {
29      code: 'ERR_INVALID_ARG_TYPE',
30      name: 'TypeError',
31      message: `The "oldPath" argument must be ${type}`
32    }
33  );
34  assert.throws(
35    () => fs.renameSync('does-not-exist', input),
36    {
37      code: 'ERR_INVALID_ARG_TYPE',
38      name: 'TypeError',
39      message: `The "newPath" argument must be ${type}`
40    }
41  );
42});
43