Browse Source

flipping default behavior - by default its details=true

pull/103/head
Harish Krishna 10 years ago
parent
commit
71499cd201
  1. 4
      sanitiser/_details.js
  2. 10
      test/unit/sanitiser/doc.js
  3. 4
      test/unit/sanitiser/search.js
  4. 4
      test/unit/sanitiser/suggest.js

4
sanitiser/_details.js

@ -4,6 +4,10 @@ function sanitize( req, default_value ){
var clean = req.clean || {};
var params= req.query;
if (default_value === undefined) {
default_value = true;
}
default_value = !!default_value;
// ensure the input params are a valid object

10
test/unit/sanitiser/doc.js

@ -10,7 +10,7 @@ var doc = require('../../../sanitiser/doc'),
defaultMissingTypeError = function(input) {
var type = input.split(delimiter)[0];
return type + ' is invalid. It must be one of these values - [' + indeces.join(', ') + ']'; },
defaultClean = { ids: [ { id: '123', type: 'geoname' } ], details: false },
defaultClean = { ids: [ { id: '123', type: 'geoname' } ], details: true },
sanitize = function(query, cb) { _sanitize({'query':query}, cb); },
inputs = {
valid: [ 'geoname:1', 'osmnode:2', 'admin0:53', 'osmway:44', 'geoname:5' ],
@ -56,7 +56,7 @@ module.exports.tests.sanitize_id = function(test, common) {
test('valid input', function(t) {
inputs.valid.forEach( function( input ){
var input_parts = input.split(delimiter);
var expected = { ids: [ { id: input_parts[1], type: input_parts[0] } ], details: false };
var expected = { ids: [ { id: input_parts[1], type: input_parts[0] } ], details: true };
sanitize({ id: input }, function( err, clean ){
t.equal(err, undefined, 'no error (' + input + ')' );
t.deepEqual(clean, expected, 'clean set correctly (' + input + ')');
@ -94,7 +94,7 @@ module.exports.tests.sanitize_ids = function(test, common) {
var input_parts = input.split(delimiter);
expected.ids.push({ id: input_parts[1], type: input_parts[0] });
});
expected.details = false;
expected.details = true;
sanitize({ id: inputs.valid }, function( err, clean ){
t.equal(err, undefined, 'no error' );
t.deepEqual(clean, expected, 'clean set correctly');
@ -136,14 +136,14 @@ module.exports.tests.sanitize_details = function(test, common) {
test('test default behavior', function(t) {
sanitize({ id:'geoname:123' }, function( err, clean ){
t.equal(clean.details, false, 'details set to false');
t.equal(clean.details, true, 'details set to true');
t.end();
});
});
};
module.exports.tests.de_dupe = function(test, common) {
var expected = { ids: [ { id: '1', type: 'geoname' }, { id: '2', type: 'osmnode' } ], details: false };
var expected = { ids: [ { id: '1', type: 'geoname' }, { id: '2', type: 'osmnode' } ], details: true };
test('duplicate ids', function(t) {
sanitize( { id: ['geoname:1', 'osmnode:2', 'geoname:1'] }, function( err, clean ){
t.equal(err, undefined, 'no error' );

4
test/unit/sanitiser/search.js

@ -8,7 +8,7 @@ var search = require('../../../sanitiser/search'),
layers: [ 'geoname', 'osmnode', 'osmway', 'admin0', 'admin1', 'admin2', 'neighborhood',
'locality', 'local_admin', 'osmaddress', 'openaddresses' ],
size: 10,
details: false
details: true
},
sanitize = function(query, cb) { _sanitize({'query':query}, cb); };
@ -300,7 +300,7 @@ module.exports.tests.sanitize_details = function(test, common) {
test('test default behavior', function(t) {
sanitize({ input: 'test', lat: 0, lon: 0 }, function( err, clean ){
t.equal(clean.details, false, 'details set to false');
t.equal(clean.details, true, 'details set to true');
t.end();
});
});

4
test/unit/sanitiser/suggest.js

@ -10,7 +10,7 @@ var suggest = require('../../../sanitiser/suggest'),
'locality', 'local_admin', 'osmaddress', 'openaddresses' ],
lon: 0,
size: 10,
details: false
details: true
},
sanitize = function(query, cb) { _sanitize({'query':query}, cb); };
@ -269,7 +269,7 @@ module.exports.tests.sanitize_details = function(test, common) {
test('test default behavior', function(t) {
sanitize({ input: 'test', lat: 0, lon: 0 }, function( err, clean ){
t.equal(clean.details, false, 'details set to false');
t.equal(clean.details, true, 'details set to true');
t.end();
});
});

Loading…
Cancel
Save