summaryrefslogtreecommitdiff
path: root/test/parallel/test-fs-copyfile.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/parallel/test-fs-copyfile.js')
-rw-r--r--test/parallel/test-fs-copyfile.js38
1 files changed, 30 insertions, 8 deletions
diff --git a/test/parallel/test-fs-copyfile.js b/test/parallel/test-fs-copyfile.js
index 2977a59847..bfda5ccfd7 100644
--- a/test/parallel/test-fs-copyfile.js
+++ b/test/parallel/test-fs-copyfile.js
@@ -70,9 +70,36 @@ common.expectsError(() => {
});
// Throws if the source path is not a string.
-assert.throws(() => {
- fs.copyFileSync(null, dest);
-}, /^TypeError: src must be a string$/);
+[false, 1, {}, [], null, undefined].forEach((i) => {
+ common.expectsError(
+ () => fs.copyFile(i, dest, common.mustNotCall()),
+ {
+ code: 'ERR_INVALID_ARG_TYPE',
+ type: TypeError
+ }
+ );
+ common.expectsError(
+ () => fs.copyFile(src, i, common.mustNotCall()),
+ {
+ code: 'ERR_INVALID_ARG_TYPE',
+ type: TypeError
+ }
+ );
+ common.expectsError(
+ () => fs.copyFileSync(i, dest),
+ {
+ code: 'ERR_INVALID_ARG_TYPE',
+ type: TypeError
+ }
+ );
+ common.expectsError(
+ () => fs.copyFileSync(src, i),
+ {
+ code: 'ERR_INVALID_ARG_TYPE',
+ type: TypeError
+ }
+ );
+});
// Throws if the source path is an invalid path.
common.expectsError(() => {
@@ -84,11 +111,6 @@ common.expectsError(() => {
' Received type string'
});
-// Throws if the destination path is not a string.
-assert.throws(() => {
- fs.copyFileSync(src, null);
-}, /^TypeError: dest must be a string$/);
-
// Throws if the destination path is an invalid path.
common.expectsError(() => {
fs.copyFileSync(src, '\u0000');