From f16eca4383914e151b35d95f4ff5b4a885cf7ea1 Mon Sep 17 00:00:00 2001 From: Mithun Sasidharan Date: Thu, 14 Dec 2017 21:44:08 +0530 Subject: [PATCH] test: improve coverage for util.promisify Add a test that confirms that non-function arguments passed to util.promisify throw an ERR_INVALID_ARG_TYPE error. PR-URL: https://github.com/nodejs/node/pull/17591 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater Reviewed-By: Rich Trott Reviewed-By: Jon Moss Reviewed-By: Michael Dawson Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil Reviewed-By: Anatoli Papirovski --- test/parallel/test-util-promisify.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/parallel/test-util-promisify.js b/test/parallel/test-util-promisify.js index 656d6d60aa8f13..235d5c40db7677 100644 --- a/test/parallel/test-util-promisify.js +++ b/test/parallel/test-util-promisify.js @@ -184,3 +184,13 @@ const stat = promisify(fs.stat); }) ]); } + +[undefined, null, true, 0, 'str', {}, [], Symbol()].forEach((input) => { + common.expectsError( + () => promisify(input), + { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError, + message: 'The "original" argument must be of type Function' + }); +});