summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorgwer <webholt@gmail.com>2017-04-23 02:01:54 +0300
committerAlexey Orlenko <eaglexrlnk@gmail.com>2017-04-30 04:08:46 +0300
commit01422769775a2ce7dfef8aa6dbda2d326f002e13 (patch)
treee3255f3dc9fd66fd3fb2a09c1fd4d39c2d81400f /test
parent0324ac686ce1c8ffc5a81e6a8290b6c5c7fd04fd (diff)
downloadandroid-node-v8-01422769775a2ce7dfef8aa6dbda2d326f002e13.tar.gz
android-node-v8-01422769775a2ce7dfef8aa6dbda2d326f002e13.tar.bz2
android-node-v8-01422769775a2ce7dfef8aa6dbda2d326f002e13.zip
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 <eaglexrlnk@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/addons-napi/test_constructor/test.js16
-rw-r--r--test/addons-napi/test_properties/test.js16
-rw-r--r--test/inspector/test-inspector.js2
-rw-r--r--test/parallel/test-child-process-default-options.js2
-rw-r--r--test/parallel/test-child-process-env.js4
-rw-r--r--test/parallel/test-child-process-exec-env.js2
-rw-r--r--test/parallel/test-child-process-spawnsync-input.js2
-rw-r--r--test/parallel/test-domain-throw-error-then-throw-from-uncaught-exception-handler.js2
-rw-r--r--test/parallel/test-domain-with-abort-on-uncaught-exception.js4
-rw-r--r--test/parallel/test-error-reporting.js2
-rw-r--r--test/parallel/test-fs-error-messages.js72
-rw-r--r--test/parallel/test-http-client-parse-error.js2
-rw-r--r--test/parallel/test-http-extra-response.js2
-rw-r--r--test/parallel/test-http-get-pipeline-problem.js2
-rw-r--r--test/parallel/test-https-strict.js6
-rw-r--r--test/parallel/test-intl.js2
-rw-r--r--test/parallel/test-listen-fd-detached-inherit.js2
-rw-r--r--test/parallel/test-listen-fd-detached.js2
-rw-r--r--test/parallel/test-module-globalpaths-nodepath.js6
-rw-r--r--test/parallel/test-net-eaddrinuse.js2
-rw-r--r--test/parallel/test-process-getactivehandles.js6
-rw-r--r--test/parallel/test-repl.js8
-rw-r--r--test/parallel/test-stream-big-packet.js2
23 files changed, 83 insertions, 83 deletions
diff --git a/test/addons-napi/test_constructor/test.js b/test/addons-napi/test_constructor/test.js
index 92440bf49e..26083db7a2 100644
--- a/test/addons-napi/test_constructor/test.js
+++ b/test/addons-napi/test_constructor/test.js
@@ -22,14 +22,14 @@ const propertyNames = [];
for (const name in test_object) {
propertyNames.push(name);
}
-assert.ok(propertyNames.indexOf('echo') >= 0);
-assert.ok(propertyNames.indexOf('readwriteValue') >= 0);
-assert.ok(propertyNames.indexOf('readonlyValue') >= 0);
-assert.ok(propertyNames.indexOf('hiddenValue') < 0);
-assert.ok(propertyNames.indexOf('readwriteAccessor1') < 0);
-assert.ok(propertyNames.indexOf('readwriteAccessor2') < 0);
-assert.ok(propertyNames.indexOf('readonlyAccessor1') < 0);
-assert.ok(propertyNames.indexOf('readonlyAccessor2') < 0);
+assert.ok(propertyNames.includes('echo'));
+assert.ok(propertyNames.includes('readwriteValue'));
+assert.ok(propertyNames.includes('readonlyValue'));
+assert.ok(!propertyNames.includes('hiddenValue'));
+assert.ok(!propertyNames.includes('readwriteAccessor1'));
+assert.ok(!propertyNames.includes('readwriteAccessor2'));
+assert.ok(!propertyNames.includes('readonlyAccessor1'));
+assert.ok(!propertyNames.includes('readonlyAccessor2'));
// The napi_writable attribute should be ignored for accessors.
test_object.readwriteAccessor1 = 1;
diff --git a/test/addons-napi/test_properties/test.js b/test/addons-napi/test_properties/test.js
index 868c603879..a8127a2786 100644
--- a/test/addons-napi/test_properties/test.js
+++ b/test/addons-napi/test_properties/test.js
@@ -21,14 +21,14 @@ const propertyNames = [];
for (const name in test_object) {
propertyNames.push(name);
}
-assert.ok(propertyNames.indexOf('echo') >= 0);
-assert.ok(propertyNames.indexOf('readwriteValue') >= 0);
-assert.ok(propertyNames.indexOf('readonlyValue') >= 0);
-assert.ok(propertyNames.indexOf('hiddenValue') < 0);
-assert.ok(propertyNames.indexOf('readwriteAccessor1') < 0);
-assert.ok(propertyNames.indexOf('readwriteAccessor2') < 0);
-assert.ok(propertyNames.indexOf('readonlyAccessor1') < 0);
-assert.ok(propertyNames.indexOf('readonlyAccessor2') < 0);
+assert.ok(propertyNames.includes('echo'));
+assert.ok(propertyNames.includes('readwriteValue'));
+assert.ok(propertyNames.includes('readonlyValue'));
+assert.ok(!propertyNames.includes('hiddenValue'));
+assert.ok(!propertyNames.includes('readwriteAccessor1'));
+assert.ok(!propertyNames.includes('readwriteAccessor2'));
+assert.ok(!propertyNames.includes('readonlyAccessor1'));
+assert.ok(!propertyNames.includes('readonlyAccessor2'));
// The napi_writable attribute should be ignored for accessors.
test_object.readwriteAccessor1 = 1;
diff --git a/test/inspector/test-inspector.js b/test/inspector/test-inspector.js
index 458c668953..0fb8b17995 100644
--- a/test/inspector/test-inspector.js
+++ b/test/inspector/test-inspector.js
@@ -35,7 +35,7 @@ function checkBadPath(err, response) {
function expectMainScriptSource(result) {
const expected = helper.mainScriptSource();
const source = result['scriptSource'];
- assert(source && (source.indexOf(expected) >= 0),
+ assert(source && (source.includes(expected)),
'Script source is wrong: ' + source);
}
diff --git a/test/parallel/test-child-process-default-options.js b/test/parallel/test-child-process-default-options.js
index 450abc60fc..3972787f8f 100644
--- a/test/parallel/test-child-process-default-options.js
+++ b/test/parallel/test-child-process-default-options.js
@@ -44,6 +44,6 @@ child.stdout.on('data', function(chunk) {
});
process.on('exit', function() {
- assert.ok(response.indexOf('HELLO=WORLD') >= 0,
+ assert.ok(response.includes('HELLO=WORLD'),
'spawn did not use process.env as default');
});
diff --git a/test/parallel/test-child-process-env.js b/test/parallel/test-child-process-env.js
index b67029f9bc..16683af4b6 100644
--- a/test/parallel/test-child-process-env.js
+++ b/test/parallel/test-child-process-env.js
@@ -50,6 +50,6 @@ child.stdout.on('data', function(chunk) {
});
process.on('exit', function() {
- assert.ok(response.indexOf('HELLO=WORLD') >= 0);
- assert.ok(response.indexOf('FOO=BAR') >= 0);
+ assert.ok(response.includes('HELLO=WORLD'));
+ assert.ok(response.includes('FOO=BAR'));
});
diff --git a/test/parallel/test-child-process-exec-env.js b/test/parallel/test-child-process-exec-env.js
index f475e5bdb7..143cd174d8 100644
--- a/test/parallel/test-child-process-exec-env.js
+++ b/test/parallel/test-child-process-exec-env.js
@@ -56,5 +56,5 @@ process.on('exit', function() {
console.log('response: ', response);
assert.strictEqual(1, success_count);
assert.strictEqual(0, error_count);
- assert.ok(response.indexOf('HELLO=WORLD') >= 0);
+ assert.ok(response.includes('HELLO=WORLD'));
});
diff --git a/test/parallel/test-child-process-spawnsync-input.js b/test/parallel/test-child-process-spawnsync-input.js
index c1f9ef149d..5b9f418cf7 100644
--- a/test/parallel/test-child-process-spawnsync-input.js
+++ b/test/parallel/test-child-process-spawnsync-input.js
@@ -52,7 +52,7 @@ function verifyBufOutput(ret) {
assert.deepStrictEqual(ret.stderr, msgErrBuf);
}
-if (process.argv.indexOf('spawnchild') !== -1) {
+if (process.argv.includes('spawnchild')) {
switch (process.argv[3]) {
case '1':
ret = spawnSync(process.execPath, args, { stdio: 'inherit' });
diff --git a/test/parallel/test-domain-throw-error-then-throw-from-uncaught-exception-handler.js b/test/parallel/test-domain-throw-error-then-throw-from-uncaught-exception-handler.js
index d2de9b2a44..cce6af84a2 100644
--- a/test/parallel/test-domain-throw-error-then-throw-from-uncaught-exception-handler.js
+++ b/test/parallel/test-domain-throw-error-then-throw-from-uncaught-exception-handler.js
@@ -17,7 +17,7 @@ const RAN_UNCAUGHT_EXCEPTION_HANDLER_EXIT_CODE = 42;
if (process.argv[2] === 'child') {
process.on('uncaughtException', common.mustCall(function onUncaught() {
- if (process.execArgv.indexOf('--abort-on-uncaught-exception') !== -1) {
+ if (process.execArgv.includes('--abort-on-uncaught-exception')) {
// When passing --abort-on-uncaught-exception to the child process,
// we want to make sure that this handler (the process' uncaughtException
// event handler) wasn't called. Unfortunately we can't parse the child
diff --git a/test/parallel/test-domain-with-abort-on-uncaught-exception.js b/test/parallel/test-domain-with-abort-on-uncaught-exception.js
index 0da8f1368f..db530fbccb 100644
--- a/test/parallel/test-domain-with-abort-on-uncaught-exception.js
+++ b/test/parallel/test-domain-with-abort-on-uncaught-exception.js
@@ -43,11 +43,11 @@ if (process.argv[2] === 'child') {
d.on('error', function(err) {
// Swallowing the error on purpose if 'throwInDomainErrHandler' is not
// set
- if (process.argv.indexOf('throwInDomainErrHandler') !== -1) {
+ if (process.argv.includes('throwInDomainErrHandler')) {
// If useTryCatch is set, wrap the throw in a try/catch block.
// This is to make sure that a caught exception does not trigger
// an abort.
- if (process.argv.indexOf('useTryCatch') !== -1) {
+ if (process.argv.includes('useTryCatch')) {
try {
throw new Error(domainErrHandlerExMessage);
} catch (e) {
diff --git a/test/parallel/test-error-reporting.js b/test/parallel/test-error-reporting.js
index 7d1b1d8cef..e7eb5abc00 100644
--- a/test/parallel/test-error-reporting.js
+++ b/test/parallel/test-error-reporting.js
@@ -36,7 +36,7 @@ function errExec(script, callback) {
assert.ok(stderr.split('\n').length > 2);
// Assert the script is mentioned in error output.
- assert.ok(stderr.indexOf(script) >= 0);
+ assert.ok(stderr.includes(script));
// Proxy the args for more tests.
callback(err, stdout, stderr);
diff --git a/test/parallel/test-fs-error-messages.js b/test/parallel/test-fs-error-messages.js
index a10e97348f..0991a798fe 100644
--- a/test/parallel/test-fs-error-messages.js
+++ b/test/parallel/test-fs-error-messages.js
@@ -34,66 +34,66 @@ const existingDir2 = path.join(common.fixturesDir, 'keys');
fs.stat(fn, function(err) {
assert.strictEqual(fn, err.path);
- assert.ok(0 <= err.message.indexOf(fn));
+ assert.ok(err.message.includes(fn));
});
fs.lstat(fn, function(err) {
- assert.ok(0 <= err.message.indexOf(fn));
+ assert.ok(err.message.includes(fn));
});
fs.readlink(fn, function(err) {
- assert.ok(0 <= err.message.indexOf(fn));
+ assert.ok(err.message.includes(fn));
});
fs.link(fn, 'foo', function(err) {
- assert.ok(0 <= err.message.indexOf(fn));
+ assert.ok(err.message.includes(fn));
});
fs.link(existingFile, existingFile2, function(err) {
- assert.ok(0 <= err.message.indexOf(existingFile));
- assert.ok(0 <= err.message.indexOf(existingFile2));
+ assert.ok(err.message.includes(existingFile));
+ assert.ok(err.message.includes(existingFile2));
});
fs.symlink(existingFile, existingFile2, function(err) {
- assert.ok(0 <= err.message.indexOf(existingFile));
- assert.ok(0 <= err.message.indexOf(existingFile2));
+ assert.ok(err.message.includes(existingFile));
+ assert.ok(err.message.includes(existingFile2));
});
fs.unlink(fn, function(err) {
- assert.ok(0 <= err.message.indexOf(fn));
+ assert.ok(err.message.includes(fn));
});
fs.rename(fn, 'foo', function(err) {
- assert.ok(0 <= err.message.indexOf(fn));
+ assert.ok(err.message.includes(fn));
});
fs.rename(existingDir, existingDir2, function(err) {
- assert.ok(0 <= err.message.indexOf(existingDir));
- assert.ok(0 <= err.message.indexOf(existingDir2));
+ assert.ok(err.message.includes(existingDir));
+ assert.ok(err.message.includes(existingDir2));
});
fs.rmdir(fn, function(err) {
- assert.ok(0 <= err.message.indexOf(fn));
+ assert.ok(err.message.includes(fn));
});
fs.mkdir(existingFile, 0o666, function(err) {
- assert.ok(0 <= err.message.indexOf(existingFile));
+ assert.ok(err.message.includes(existingFile));
});
fs.rmdir(existingFile, function(err) {
- assert.ok(0 <= err.message.indexOf(existingFile));
+ assert.ok(err.message.includes(existingFile));
});
fs.chmod(fn, 0o666, function(err) {
- assert.ok(0 <= err.message.indexOf(fn));
+ assert.ok(err.message.includes(fn));
});
fs.open(fn, 'r', 0o666, function(err) {
- assert.ok(0 <= err.message.indexOf(fn));
+ assert.ok(err.message.includes(fn));
});
fs.readFile(fn, function(err) {
- assert.ok(0 <= err.message.indexOf(fn));
+ assert.ok(err.message.includes(fn));
});
// Sync
@@ -106,7 +106,7 @@ try {
fs.statSync(fn);
} catch (err) {
errors.push('stat');
- assert.ok(0 <= err.message.indexOf(fn));
+ assert.ok(err.message.includes(fn));
}
try {
@@ -114,7 +114,7 @@ try {
fs.mkdirSync(existingFile, 0o666);
} catch (err) {
errors.push('mkdir');
- assert.ok(0 <= err.message.indexOf(existingFile));
+ assert.ok(err.message.includes(existingFile));
}
try {
@@ -122,7 +122,7 @@ try {
fs.chmodSync(fn, 0o666);
} catch (err) {
errors.push('chmod');
- assert.ok(0 <= err.message.indexOf(fn));
+ assert.ok(err.message.includes(fn));
}
try {
@@ -130,7 +130,7 @@ try {
fs.lstatSync(fn);
} catch (err) {
errors.push('lstat');
- assert.ok(0 <= err.message.indexOf(fn));
+ assert.ok(err.message.includes(fn));
}
try {
@@ -138,7 +138,7 @@ try {
fs.readlinkSync(fn);
} catch (err) {
errors.push('readlink');
- assert.ok(0 <= err.message.indexOf(fn));
+ assert.ok(err.message.includes(fn));
}
try {
@@ -146,7 +146,7 @@ try {
fs.linkSync(fn, 'foo');
} catch (err) {
errors.push('link');
- assert.ok(0 <= err.message.indexOf(fn));
+ assert.ok(err.message.includes(fn));
}
try {
@@ -154,8 +154,8 @@ try {
fs.linkSync(existingFile, existingFile2);
} catch (err) {
errors.push('link');
- assert.ok(0 <= err.message.indexOf(existingFile));
- assert.ok(0 <= err.message.indexOf(existingFile2));
+ assert.ok(err.message.includes(existingFile));
+ assert.ok(err.message.includes(existingFile2));
}
try {
@@ -163,8 +163,8 @@ try {
fs.symlinkSync(existingFile, existingFile2);
} catch (err) {
errors.push('symlink');
- assert.ok(0 <= err.message.indexOf(existingFile));
- assert.ok(0 <= err.message.indexOf(existingFile2));
+ assert.ok(err.message.includes(existingFile));
+ assert.ok(err.message.includes(existingFile2));
}
try {
@@ -172,7 +172,7 @@ try {
fs.unlinkSync(fn);
} catch (err) {
errors.push('unlink');
- assert.ok(0 <= err.message.indexOf(fn));
+ assert.ok(err.message.includes(fn));
}
try {
@@ -180,7 +180,7 @@ try {
fs.rmdirSync(fn);
} catch (err) {
errors.push('rmdir');
- assert.ok(0 <= err.message.indexOf(fn));
+ assert.ok(err.message.includes(fn));
}
try {
@@ -188,7 +188,7 @@ try {
fs.rmdirSync(existingFile);
} catch (err) {
errors.push('rmdir');
- assert.ok(0 <= err.message.indexOf(existingFile));
+ assert.ok(err.message.includes(existingFile));
}
try {
@@ -196,7 +196,7 @@ try {
fs.openSync(fn, 'r');
} catch (err) {
errors.push('opens');
- assert.ok(0 <= err.message.indexOf(fn));
+ assert.ok(err.message.includes(fn));
}
try {
@@ -204,7 +204,7 @@ try {
fs.renameSync(fn, 'foo');
} catch (err) {
errors.push('rename');
- assert.ok(0 <= err.message.indexOf(fn));
+ assert.ok(err.message.includes(fn));
}
try {
@@ -212,8 +212,8 @@ try {
fs.renameSync(existingDir, existingDir2);
} catch (err) {
errors.push('rename');
- assert.ok(0 <= err.message.indexOf(existingDir));
- assert.ok(0 <= err.message.indexOf(existingDir2));
+ assert.ok(err.message.includes(existingDir));
+ assert.ok(err.message.includes(existingDir2));
}
try {
@@ -221,7 +221,7 @@ try {
fs.readdirSync(fn);
} catch (err) {
errors.push('readdir');
- assert.ok(0 <= err.message.indexOf(fn));
+ assert.ok(err.message.includes(fn));
}
process.on('exit', function() {
diff --git a/test/parallel/test-http-client-parse-error.js b/test/parallel/test-http-client-parse-error.js
index f82627af81..074f24063f 100644
--- a/test/parallel/test-http-client-parse-error.js
+++ b/test/parallel/test-http-client-parse-error.js
@@ -47,7 +47,7 @@ net.createServer(function(c) {
path: '/'
}).on('error', function(e) {
console.log('got error from client');
- assert.ok(e.message.indexOf('Parse Error') >= 0);
+ assert.ok(e.message.includes('Parse Error'));
assert.strictEqual(e.code, 'HPE_INVALID_CONSTANT');
parseErrors++;
}).end();
diff --git a/test/parallel/test-http-extra-response.js b/test/parallel/test-http-extra-response.js
index 61355449d1..e83171378d 100644
--- a/test/parallel/test-http-extra-response.js
+++ b/test/parallel/test-http-extra-response.js
@@ -49,7 +49,7 @@ const server = net.createServer(function(socket) {
socket.on('data', function(chunk) {
postBody += chunk;
- if (postBody.indexOf('\r\n') > -1) {
+ if (postBody.includes('\r\n')) {
socket.write(fullResponse);
// omg, I wrote the response twice, what a terrible HTTP server I am.
socket.end(fullResponse);
diff --git a/test/parallel/test-http-get-pipeline-problem.js b/test/parallel/test-http-get-pipeline-problem.js
index cfe4b12b1a..762100511a 100644
--- a/test/parallel/test-http-get-pipeline-problem.js
+++ b/test/parallel/test-http-get-pipeline-problem.js
@@ -94,7 +94,7 @@ function checkFiles() {
for (let i = 0; i < total; i++) {
const fn = i + '.jpg';
- assert.ok(files.indexOf(fn) >= 0, "couldn't find '" + fn + "'");
+ assert.ok(files.includes(fn), "couldn't find '" + fn + "'");
const stat = fs.statSync(common.tmpDir + '/' + fn);
assert.strictEqual(image.length, stat.size,
"size doesn't match on '" + fn +
diff --git a/test/parallel/test-https-strict.js b/test/parallel/test-https-strict.js
index 70e11d2c8b..01fad2f594 100644
--- a/test/parallel/test-https-strict.js
+++ b/test/parallel/test-https-strict.js
@@ -130,11 +130,11 @@ function makeReq(path, port, error, host, ca) {
options.agent = agent0;
} else {
if (!Array.isArray(ca)) ca = [ca];
- if (-1 !== ca.indexOf(ca1) && -1 !== ca.indexOf(ca2)) {
+ if (ca.includes(ca1) && ca.includes(ca2)) {
options.agent = agent3;
- } else if (-1 !== ca.indexOf(ca1)) {
+ } else if (ca.includes(ca1)) {
options.agent = agent1;
- } else if (-1 !== ca.indexOf(ca2)) {
+ } else if (ca.includes(ca2)) {
options.agent = agent2;
} else {
options.agent = agent0;
diff --git a/test/parallel/test-intl.js b/test/parallel/test-intl.js
index 979506e2ab..d10c76283c 100644
--- a/test/parallel/test-intl.js
+++ b/test/parallel/test-intl.js
@@ -34,7 +34,7 @@ if (enablei18n === undefined) {
// Else, returns false
function haveLocale(loc) {
const locs = process.config.variables.icu_locales.split(',');
- return locs.indexOf(loc) !== -1;
+ return locs.includes(loc);
}
// Always run these. They should always pass, even if the locale
diff --git a/test/parallel/test-listen-fd-detached-inherit.js b/test/parallel/test-listen-fd-detached-inherit.js
index 808ee25f01..f3f33055ac 100644
--- a/test/parallel/test-listen-fd-detached-inherit.js
+++ b/test/parallel/test-listen-fd-detached-inherit.js
@@ -50,7 +50,7 @@ function test() {
let json = '';
parent.stdout.on('data', function(c) {
json += c.toString();
- if (json.indexOf('\n') !== -1) next();
+ if (json.includes('\n')) next();
});
function next() {
console.error('output from parent = %s', json);
diff --git a/test/parallel/test-listen-fd-detached.js b/test/parallel/test-listen-fd-detached.js
index de4da62ad5..8a40cce56b 100644
--- a/test/parallel/test-listen-fd-detached.js
+++ b/test/parallel/test-listen-fd-detached.js
@@ -50,7 +50,7 @@ function test() {
let json = '';
parent.stdout.on('data', function(c) {
json += c.toString();
- if (json.indexOf('\n') !== -1) next();
+ if (json.includes('\n')) next();
});
function next() {
console.error('output from parent = %s', json);
diff --git a/test/parallel/test-module-globalpaths-nodepath.js b/test/parallel/test-module-globalpaths-nodepath.js
index 5368848f37..f0366aedab 100644
--- a/test/parallel/test-module-globalpaths-nodepath.js
+++ b/test/parallel/test-module-globalpaths-nodepath.js
@@ -39,8 +39,8 @@ if (common.isWindows) {
mod._initPaths();
-assert.ok(mod.globalPaths.indexOf(partA) !== -1);
-assert.ok(mod.globalPaths.indexOf(partB) !== -1);
-assert.ok(mod.globalPaths.indexOf(partC) === -1);
+assert.ok(mod.globalPaths.includes(partA));
+assert.ok(mod.globalPaths.includes(partB));
+assert.ok(!mod.globalPaths.includes(partC));
assert.ok(Array.isArray(mod.globalPaths));
diff --git a/test/parallel/test-net-eaddrinuse.js b/test/parallel/test-net-eaddrinuse.js
index a89168936d..8c3bcc6cf1 100644
--- a/test/parallel/test-net-eaddrinuse.js
+++ b/test/parallel/test-net-eaddrinuse.js
@@ -30,7 +30,7 @@ const server2 = net.createServer(function(socket) {
});
server1.listen(0, function() {
server2.on('error', function(error) {
- assert.strictEqual(true, error.message.indexOf('EADDRINUSE') >= 0);
+ assert.strictEqual(true, error.message.includes('EADDRINUSE'));
server1.close();
});
server2.listen(this.address().port);
diff --git a/test/parallel/test-process-getactivehandles.js b/test/parallel/test-process-getactivehandles.js
index 8ceb2bcd2a..2db3da3c56 100644
--- a/test/parallel/test-process-getactivehandles.js
+++ b/test/parallel/test-process-getactivehandles.js
@@ -33,15 +33,15 @@ function checkAll() {
const handles = process._getActiveHandles();
clients.forEach(function(item) {
- assert.ok(handles.indexOf(item) > -1);
+ assert.ok(handles.includes(item));
item.destroy();
});
connections.forEach(function(item) {
- assert.ok(handles.indexOf(item) > -1);
+ assert.ok(handles.includes(item));
item.end();
});
- assert.ok(handles.indexOf(server) > -1);
+ assert.ok(handles.includes(server));
server.close();
}
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 = '';
diff --git a/test/parallel/test-stream-big-packet.js b/test/parallel/test-stream-big-packet.js
index 2ec69cf2cb..aeddfb2052 100644
--- a/test/parallel/test-stream-big-packet.js
+++ b/test/parallel/test-stream-big-packet.js
@@ -43,7 +43,7 @@ util.inherits(TestStream, stream.Transform);
TestStream.prototype._transform = function(chunk, encoding, done) {
if (!passed) {
// Char 'a' only exists in the last write
- passed = chunk.toString().indexOf('a') >= 0;
+ passed = chunk.toString().includes('a');
}
done();
};