From fe8297ca92874770880e09e052c94f6ece5b2939 Mon Sep 17 00:00:00 2001 From: Ashish Kaila Date: Wed, 18 Oct 2017 13:59:48 -0700 Subject: [PATCH] util: expand test coverage for util.deprecate Test for invalid argument types passed to code on util.deprecate. PR-URL: https://github.com/nodejs/node/pull/16305 Reviewed-By: Anatoli Papirovski Reviewed-By: Gireesh Punathil Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- test/parallel/test-util-deprecate-invalid-code.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 test/parallel/test-util-deprecate-invalid-code.js diff --git a/test/parallel/test-util-deprecate-invalid-code.js b/test/parallel/test-util-deprecate-invalid-code.js new file mode 100644 index 00000000000000..057e095424dd3f --- /dev/null +++ b/test/parallel/test-util-deprecate-invalid-code.js @@ -0,0 +1,12 @@ +'use strict'; + +const common = require('../common'); +const util = require('util'); + +[1, true, false, null, {}].forEach((notString) => { + common.expectsError(() => util.deprecate(() => {}, 'message', notString), { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError, + message: 'The "code" argument must be of type string' + }); +});