From 465d9f2bc140bc3a58a2f36e307ed145f89d7e64 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Tue, 1 Nov 2016 17:27:26 -0400 Subject: [PATCH] Replace .indexOf(...) != -1 with .includes() --- test/unit/controller/index.js | 4 ++-- test/unit/mock/backend.js | 2 +- test/unit/sanitizer/_categories.js | 4 ++-- test/unit/sanitizer/search.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/unit/controller/index.js b/test/unit/controller/index.js index cffe1030..c48745ef 100644 --- a/test/unit/controller/index.js +++ b/test/unit/controller/index.js @@ -58,7 +58,7 @@ module.exports.tests.info_html = function(test, common) { var res = { send: function( content ){ t.equal(typeof content, 'string', 'returns string'); t.assert(content.indexOf(style) === 0, 'style set'); - t.assert(content.indexOf(mockText) !== -1, 'file content added'); + t.true(content.includes(mockText), 'file content added'); t.end(); }}; controller( req, res ); @@ -74,4 +74,4 @@ module.exports.all = function (tape, common) { for( var testCase in module.exports.tests ){ module.exports.tests[testCase](test, common); } -}; \ No newline at end of file +}; diff --git a/test/unit/mock/backend.js b/test/unit/mock/backend.js index 739ed2cb..d7aa3605 100644 --- a/test/unit/mock/backend.js +++ b/test/unit/mock/backend.js @@ -76,7 +76,7 @@ function setup( key, cmdCb ){ client: { mget: function( cmd, cb ){ if( 'function' === typeof cmdCb ){ cmdCb( cmd ); } - return responses[key.indexOf('mget') === -1 ? 'client/mget/ok/1' : key].apply( this, arguments ); + return responses[key.includes('mget') ? key : 'client/mget/ok/1'].apply( this, arguments ); }, suggest: function( cmd, cb ){ if( 'function' === typeof cmdCb ){ cmdCb( cmd ); } diff --git a/test/unit/sanitizer/_categories.js b/test/unit/sanitizer/_categories.js index 64e9555f..17cb3724 100644 --- a/test/unit/sanitizer/_categories.js +++ b/test/unit/sanitizer/_categories.js @@ -61,7 +61,7 @@ module.exports.tests.valid_categories = function(test, common) { var validCategories = { isValidCategory: function (cat) { isValidCategoryCalled++; - return ['food','health','financial','education','government'].indexOf(cat) !== -1; } + return ['food','health','financial','education','government'].includes(cat); } }; test('single category', function(t) { @@ -113,7 +113,7 @@ module.exports.tests.invalid_categories = function(test, common) { var validCategories = { isValidCategory: function (cat) { isValidCategoryCalled++; - return ['food','health','financial','education','government'].indexOf(cat) !== -1; } + return ['food','health','financial','education','government'].includes(cat); } }; test('garbage category', function(t) { diff --git a/test/unit/sanitizer/search.js b/test/unit/sanitizer/search.js index b656d943..cf895ba5 100644 --- a/test/unit/sanitizer/search.js +++ b/test/unit/sanitizer/search.js @@ -34,7 +34,7 @@ module.exports.tests.sanitize = function(test, common) { }, '../sanitizer/_targets': function(type) { - if (['layers', 'sources'].indexOf(type) !== -1) { + if (['layers', 'sources'].includes(type)) { return function() { called_sanitizers.push('_targets/' + type); return { errors: [], warnings: [] };