Skip to content

Commit 807e99b

Browse files
edsadritaloacasas
authored andcommitted
test: validate errors in test-buffer-indexof
* validate errors in assert.throws * use arrow functions PR-URL: #10752 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 32da59a commit 807e99b

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

test/parallel/test-buffer-indexof.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -337,15 +337,20 @@ assert.strictEqual(Buffer.from('aaaaa').indexOf('b', 'ucs2'), -1);
337337
}
338338
}
339339

340-
assert.throws(function() {
341-
b.indexOf(function() { });
342-
});
343-
assert.throws(function() {
340+
const argumentExpected =
341+
/^TypeError: "val" argument must be string, number or Buffer$/;
342+
343+
assert.throws(() => {
344+
b.indexOf(() => { });
345+
}, argumentExpected);
346+
347+
assert.throws(() => {
344348
b.indexOf({});
345-
});
346-
assert.throws(function() {
349+
}, argumentExpected);
350+
351+
assert.throws(() => {
347352
b.indexOf([]);
348-
});
353+
}, argumentExpected);
349354

350355
// All code for handling encodings is shared between Buffer.indexOf and
351356
// Buffer.lastIndexOf, so only testing the separate lastIndexOf semantics.

0 commit comments

Comments
 (0)