Browse Source

Replace .indexOf(...) != -1 with .includes()

es6-include
Julian Simioni 8 years ago
parent
commit
465d9f2bc1
No known key found for this signature in database
GPG Key ID: 6DAD08919FDBF563
  1. 4
      test/unit/controller/index.js
  2. 2
      test/unit/mock/backend.js
  3. 4
      test/unit/sanitizer/_categories.js
  4. 2
      test/unit/sanitizer/search.js

4
test/unit/controller/index.js

@ -58,7 +58,7 @@ module.exports.tests.info_html = function(test, common) {
var res = { send: function( content ){ var res = { send: function( content ){
t.equal(typeof content, 'string', 'returns string'); t.equal(typeof content, 'string', 'returns string');
t.assert(content.indexOf(style) === 0, 'style set'); 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(); t.end();
}}; }};
controller( req, res ); controller( req, res );
@ -74,4 +74,4 @@ module.exports.all = function (tape, common) {
for( var testCase in module.exports.tests ){ for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common); module.exports.tests[testCase](test, common);
} }
}; };

2
test/unit/mock/backend.js

@ -76,7 +76,7 @@ function setup( key, cmdCb ){
client: { client: {
mget: function( cmd, cb ){ mget: function( cmd, cb ){
if( 'function' === typeof cmdCb ){ cmdCb( cmd ); } 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 ){ suggest: function( cmd, cb ){
if( 'function' === typeof cmdCb ){ cmdCb( cmd ); } if( 'function' === typeof cmdCb ){ cmdCb( cmd ); }

4
test/unit/sanitizer/_categories.js

@ -61,7 +61,7 @@ module.exports.tests.valid_categories = function(test, common) {
var validCategories = { var validCategories = {
isValidCategory: function (cat) { isValidCategory: function (cat) {
isValidCategoryCalled++; isValidCategoryCalled++;
return ['food','health','financial','education','government'].indexOf(cat) !== -1; } return ['food','health','financial','education','government'].includes(cat); }
}; };
test('single category', function(t) { test('single category', function(t) {
@ -113,7 +113,7 @@ module.exports.tests.invalid_categories = function(test, common) {
var validCategories = { var validCategories = {
isValidCategory: function (cat) { isValidCategory: function (cat) {
isValidCategoryCalled++; isValidCategoryCalled++;
return ['food','health','financial','education','government'].indexOf(cat) !== -1; } return ['food','health','financial','education','government'].includes(cat); }
}; };
test('garbage category', function(t) { test('garbage category', function(t) {

2
test/unit/sanitizer/search.js

@ -34,7 +34,7 @@ module.exports.tests.sanitize = function(test, common) {
}, },
'../sanitizer/_targets': function(type) { '../sanitizer/_targets': function(type) {
if (['layers', 'sources'].indexOf(type) !== -1) { if (['layers', 'sources'].includes(type)) {
return function() { return function() {
called_sanitizers.push('_targets/' + type); called_sanitizers.push('_targets/' + type);
return { errors: [], warnings: [] }; return { errors: [], warnings: [] };

Loading…
Cancel
Save