From 1e3dac6b2d1764602bd464a5484f5460ce33f2de Mon Sep 17 00:00:00 2001 From: Adrian Estrada Date: Wed, 11 Jan 2017 22:14:36 -0500 Subject: [PATCH] test: validate errors in test-buffer-indexof * validate errors in assert.throws * use arrow functions PR-URL: https://github.com/nodejs/node/pull/10752 Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig --- test/parallel/test-buffer-indexof.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-buffer-indexof.js b/test/parallel/test-buffer-indexof.js index ebb8c1fe586842..208fed08cdf45c 100644 --- a/test/parallel/test-buffer-indexof.js +++ b/test/parallel/test-buffer-indexof.js @@ -344,15 +344,20 @@ assert.strictEqual(Buffer.from('aaaaa').indexOf('b', 'ucs2'), -1); } } -assert.throws(function() { - b.indexOf(function() { }); -}); -assert.throws(function() { +const argumentExpected = + /^TypeError: "val" argument must be string, number, Buffer or Uint8Array$/; + +assert.throws(() => { + b.indexOf(() => { }); +}, argumentExpected); + +assert.throws(() => { b.indexOf({}); -}); -assert.throws(function() { +}, argumentExpected); + +assert.throws(() => { b.indexOf([]); -}); +}, argumentExpected); // All code for handling encodings is shared between Buffer.indexOf and // Buffer.lastIndexOf, so only testing the separate lastIndexOf semantics.