From 01422769775a2ce7dfef8aa6dbda2d326f002e13 Mon Sep 17 00:00:00 2001 From: gwer Date: Sun, 23 Apr 2017 02:01:54 +0300 Subject: test: replace indexOf with includes Start the transition to Array.prototype.includes() and String.prototype.includes(). This commit refactors most of the comparisons of Array.prototype.indexOf() and String.prototype.indexOf() return values with -1 to the former methods in tests. PR-URL: https://github.com/nodejs/node/pull/12604 Refs: https://github.com/nodejs/node/issues/12586 Reviewed-By: Alexey Orlenko Reviewed-By: James M Snell Reviewed-By: Gibson Fahnestock --- test/parallel/test-repl.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/parallel/test-repl.js') diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 7a019cc554..824f4b094c 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -88,7 +88,7 @@ function error_test() { client_unix.expect : JSON.stringify(client_unix.expect))); - if (read_buffer.indexOf(prompt_unix) !== -1) { + if (read_buffer.includes(prompt_unix)) { // if it's an exact match, then don't do the regexp if (read_buffer !== client_unix.expect) { let expect = client_unix.expect; @@ -109,7 +109,7 @@ function error_test() { tcp_test(); } - } else if (read_buffer.indexOf(prompt_multiline) !== -1) { + } else if (read_buffer.includes(prompt_multiline)) { // Check that you meant to send a multiline test assert.strictEqual(prompt_multiline, client_unix.expect); read_buffer = ''; @@ -454,7 +454,7 @@ function tcp_test() { read_buffer += data.toString('ascii', 0, data.length); console.error('TCP data: ' + JSON.stringify(read_buffer) + ', expecting ' + JSON.stringify(client_tcp.expect)); - if (read_buffer.indexOf(prompt_tcp) !== -1) { + if (read_buffer.includes(prompt_tcp)) { assert.strictEqual(client_tcp.expect, read_buffer); console.error('match'); read_buffer = ''; @@ -524,7 +524,7 @@ function unix_test() { read_buffer += data.toString('ascii', 0, data.length); console.error('Unix data: ' + JSON.stringify(read_buffer) + ', expecting ' + JSON.stringify(client_unix.expect)); - if (read_buffer.indexOf(prompt_unix) !== -1) { + if (read_buffer.includes(prompt_unix)) { assert.strictEqual(client_unix.expect, read_buffer); console.error('match'); read_buffer = ''; -- cgit v1.2.3