From 01c1286110ae836e17b9ad2a25c1ee8af05f3888 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 15 Feb 2018 23:38:11 -0800 Subject: [PATCH] Update error message for test-buffer-bad-overload.js --- index.js | 4 +++- test/node/test-buffer-bad-overload.js | 13 +++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 8ea2326..8e44f6a 100644 --- a/index.js +++ b/index.js @@ -119,7 +119,9 @@ Buffer.poolSize = 8192 // not used by this implementation function from (value, encodingOrOffset, length) { if (typeof value === 'number') { - throw new TypeError('"value" argument must not be a number') + throw new TypeError( + 'The "value" argument must not be of type number. Received type number' + ) } if (isArrayBuffer(value) || (value && isArrayBuffer(value.buffer))) { diff --git a/test/node/test-buffer-bad-overload.js b/test/node/test-buffer-bad-overload.js index 282227d..ea2406f 100644 --- a/test/node/test-buffer-bad-overload.js +++ b/test/node/test-buffer-bad-overload.js @@ -1,16 +1,21 @@ 'use strict'; var Buffer = require('../../').Buffer; - - -var assert = require('assert'); +const common = require('./common'); +const assert = require('assert'); assert.doesNotThrow(function() { Buffer.allocUnsafe(10); }); +const err = common.expectsError({ + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError, + message: 'The "value" argument must not be of type number. ' + + 'Received type number' +}); assert.throws(function() { Buffer.from(10, 'hex'); -}); +}, err); assert.doesNotThrow(function() { Buffer.from('deadbeaf', 'hex'); -- 2.34.1