summaryrefslogtreecommitdiff
path: root/test/parallel/test-buffer-indexof.js
diff options
context:
space:
mode:
authorAdrian Estrada <edsadr@gmail.com>2017-01-11 22:14:36 -0500
committerLuigi Pinca <luigipinca@gmail.com>2017-01-16 11:18:18 +0100
commitf51d4f34ae9227173ef6dc471bafe27f7e92b791 (patch)
tree719aca287b76d0c7947f9d0f23555034573d2e73 /test/parallel/test-buffer-indexof.js
parent77be180f49096c2789c08d31744f5ef16fe340a1 (diff)
downloadandroid-node-v8-f51d4f34ae9227173ef6dc471bafe27f7e92b791.tar.gz
android-node-v8-f51d4f34ae9227173ef6dc471bafe27f7e92b791.tar.bz2
android-node-v8-f51d4f34ae9227173ef6dc471bafe27f7e92b791.zip
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 <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'test/parallel/test-buffer-indexof.js')
-rw-r--r--test/parallel/test-buffer-indexof.js19
1 files changed, 12 insertions, 7 deletions
diff --git a/test/parallel/test-buffer-indexof.js b/test/parallel/test-buffer-indexof.js
index ebb8c1fe58..208fed08cd 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.