summaryrefslogtreecommitdiff
path: root/test/parallel/test-fs-make-callback.js
diff options
context:
space:
mode:
authorSakthipriyan Vairamani (thefourtheye) <thechargingvolcano@gmail.com>2017-04-21 10:16:15 +0530
committerSakthipriyan Vairamani (thefourtheye) <thechargingvolcano@gmail.com>2017-05-10 00:04:01 +0530
commit4cb5f3daa350421e4eb4622dc818633d3a0659b3 (patch)
tree490ce4076130828921ddb6a7bfd45e49039d17de /test/parallel/test-fs-make-callback.js
parente429f9a42af94f039621a1bf9f21ad424aa00558 (diff)
downloadnode-new-4cb5f3daa350421e4eb4622dc818633d3a0659b3.tar.gz
fs: throw on invalid callbacks for async functions
If an asynchronous function is passed no callback function, there is no way to return the result. This patch throws an error if the callback passed is not valid or none passed at all. PR-URL: https://github.com/nodejs/node/pull/12562 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'test/parallel/test-fs-make-callback.js')
-rw-r--r--test/parallel/test-fs-make-callback.js8
1 files changed, 1 insertions, 7 deletions
diff --git a/test/parallel/test-fs-make-callback.js b/test/parallel/test-fs-make-callback.js
index 8a19e1cc96..aed5811fc7 100644
--- a/test/parallel/test-fs-make-callback.js
+++ b/test/parallel/test-fs-make-callback.js
@@ -2,11 +2,10 @@
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
-const cbTypeError = /^TypeError: "callback" argument must be a function$/;
+const cbTypeError = common.expectsError({code: 'ERR_INVALID_CALLBACK'});
const callbackThrowValues = [null, true, false, 0, 1, 'foo', /foo/, [], {}];
const { sep } = require('path');
-const warn = 'Calling an asynchronous function without callback is deprecated.';
common.refreshTmpDir();
@@ -17,11 +16,6 @@ function testMakeCallback(cb) {
};
}
-common.expectWarning('DeprecationWarning', warn);
-
-// Passing undefined/nothing calls rethrow() internally, which emits a warning
-assert.doesNotThrow(testMakeCallback());
-
function invalidCallbackThrowsTests() {
callbackThrowValues.forEach((value) => {
assert.throws(testMakeCallback(value), cbTypeError);