Browse Source

removed unused predicate

pull/912/head
Stephen Hess 8 years ago
parent
commit
257ee8161f
  1. 5
      controller/predicates/is_single_field_analysis.js
  2. 1
      routes/v1.js
  3. 94
      test/unit/controller/predicates/is_single_field_analysis.js
  4. 1
      test/unit/run.js

5
controller/predicates/is_single_field_analysis.js

@ -1,5 +0,0 @@
const _ = require('lodash');
// predicate that determines if parsed_text contains only the supplied property
module.exports = property => (req, res) =>
_.isEqual(_.keys(_.get(req, ['clean', 'parsed_text'])), [property]);

1
routes/v1.js

@ -75,7 +75,6 @@ const hasRequestErrors = require('../controller/predicates/has_request_errors');
const isCoarseReverse = require('../controller/predicates/is_coarse_reverse');
const isAdminOnlyAnalysis = require('../controller/predicates/is_admin_only_analysis');
const hasResultsAtLayers = require('../controller/predicates/has_results_at_layers');
const isSingleFieldAnalysis = require('../controller/predicates/is_single_field_analysis');
const isAddressItParse = require('../controller/predicates/is_addressit_parse');
const hasRequestCategories = require('../controller/predicates/has_request_parameter')('categories');
const isOnlyNonAdminLayers = require('../controller/predicates/is_only_non_admin_layers');

94
test/unit/controller/predicates/is_single_field_analysis.js

@ -1,94 +0,0 @@
'use strict';
const _ = require('lodash');
const is_single_field_analysis = require('../../../../controller/predicates/is_single_field_analysis');
module.exports.tests = {};
module.exports.tests.interface = (test, common) => {
test('valid interface', (t) => {
t.ok(_.isFunction(is_single_field_analysis), 'is_single_field_analysis is a function');
t.end();
});
};
module.exports.tests.true_conditions = (test, common) => {
test('defined request.clean.parsed_text.property should return true', (t) => {
const req = {
clean: {
parsed_text: {
property: 'value'
}
}
};
t.ok(is_single_field_analysis('property')(req));
t.end();
});
};
module.exports.tests.false_conditions = (test, common) => {
test('undefined request should return false', (t) => {
t.notOk(is_single_field_analysis('property')());
t.end();
});
test('undefined request.clean should return false', (t) => {
const req = {};
t.notOk(is_single_field_analysis('property')(req));
t.end();
});
test('undefined request.clean.parsed_text should return false', (t) => {
const req = {
clean: {}
};
t.notOk(is_single_field_analysis('property')(req));
t.end();
});
test('request.clean.parsed_text with none of the supplied properties should return false', (t) => {
const req = {
clean: {
parsed_text: {}
}
};
t.notOk(is_single_field_analysis('property')(req));
t.end();
});
test('request.clean.parsed_text with none of the supplied properties should return false', (t) => {
const req = {
clean: {
parsed_text: {
property: 'value',
another_property: 'value'
}
}
};
t.notOk(is_single_field_analysis('property')(req));
t.end();
});
};
module.exports.all = (tape, common) => {
function test(name, testFunction) {
return tape(`GET /is_single_field_analysis ${name}`, testFunction);
}
for( const testCase in module.exports.tests ){
module.exports.tests[testCase](test, common);
}
};

1
test/unit/run.js

@ -29,7 +29,6 @@ var tests = [
require('./controller/predicates/is_only_non_admin_layers'),
require('./controller/predicates/is_request_sources_only_whosonfirst'),
require('./controller/predicates/is_service_enabled'),
require('./controller/predicates/is_single_field_analysis'),
require('./helper/diffPlaces'),
require('./helper/geojsonify'),
require('./helper/logging'),

Loading…
Cancel
Save