From f40503a0747ab518590b03eef166a3b4b5aebef4 Mon Sep 17 00:00:00 2001 From: Bnaya Peretz Date: Wed, 21 Jun 2017 20:10:58 +0300 Subject: [PATCH] test: refactor indexOf uses to es6 equivalents refactor indexOf uses to es6 where applicable Refs: https://github.com/nodejs/node/issues/12586 --- test/pummel/test-dtrace-jsstack.js | 6 +++--- test/pummel/test-regress-GH-814.js | 2 +- test/pummel/test-regress-GH-814_2.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/pummel/test-dtrace-jsstack.js b/test/pummel/test-dtrace-jsstack.js index 2f2506031dee02..92dcc5b24b7534 100644 --- a/test/pummel/test-dtrace-jsstack.js +++ b/test/pummel/test-dtrace-jsstack.js @@ -86,14 +86,14 @@ dtrace.on('exit', function(code) { for (let i = 0; i < lines.length; i++) { const line = lines[i]; - if (line.indexOf(sentinel) === -1 || frames.length === 0) + if (!line.includes(sentinel) || frames.length === 0) continue; const frame = line.substr(line.indexOf(sentinel) + sentinel.length); const top = frames.shift(); - assert.strictEqual(frame.indexOf(top), 0, - `unexpected frame where ${top} was expected`); + assert.ok(frame.startsWith(top), + `unexpected frame where ${top} was expected`); } assert.strictEqual(frames.length, 0, diff --git a/test/pummel/test-regress-GH-814.js b/test/pummel/test-regress-GH-814.js index 898f30c89c05d2..a43a67fe77cc2e 100644 --- a/test/pummel/test-regress-GH-814.js +++ b/test/pummel/test-regress-GH-814.js @@ -51,7 +51,7 @@ const tail = require('child_process').spawn('tail', ['-f', testFileName]); tail.stdout.on('data', tailCB); function tailCB(data) { - PASS = data.toString().indexOf('.') < 0; + PASS = !data.toString().includes('.'); } diff --git a/test/pummel/test-regress-GH-814_2.js b/test/pummel/test-regress-GH-814_2.js index 5161fdb2706664..516a8727c65012 100644 --- a/test/pummel/test-regress-GH-814_2.js +++ b/test/pummel/test-regress-GH-814_2.js @@ -35,7 +35,7 @@ const tailProc = require('child_process').spawn('tail', ['-f', testFileName]); tailProc.stdout.on('data', tailCB); function tailCB(data) { - PASS = data.toString().indexOf('.') < 0; + PASS = !data.toString().includes('.'); if (PASS) { //console.error('i');