test: improve test-buffer-includes.js

* verify error message
* use arrow funcs

PR-URL: https://github.com/nodejs/node/pull/11203
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
toboid 2017-02-06 21:08:34 +00:00 committed by James M Snell
parent f65aa08b52
commit 1544d8f04b

View File

@ -275,15 +275,17 @@ for (let lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) {
}
}
assert.throws(function() {
b.includes(function() { });
});
assert.throws(function() {
const expectedError =
/^TypeError: "val" argument must be string, number, Buffer or Uint8Array$/;
assert.throws(() => {
b.includes(() => {});
}, expectedError);
assert.throws(() => {
b.includes({});
});
assert.throws(function() {
}, expectedError);
assert.throws(() => {
b.includes([]);
});
}, expectedError);
// test truncation of Number arguments to uint8
{