Browse Source

Whitespace

pull/204/head
Julian Simioni 9 years ago committed by Julian Simioni
parent
commit
4e74e9b681
  1. 2
      app.js
  2. 8
      controller/doc.js
  3. 1
      sanitiser/doc.js
  4. 2
      test/ciao/doc/msuccess.coffee
  5. 2
      test/ciao/doc/success.coffee
  6. 5
      test/unit/controller/doc.js
  7. 2
      test/unit/run.js
  8. 10
      test/unit/sanitiser/doc.js

2
app.js

@ -54,4 +54,4 @@ app.use( require('./middleware/404') );
app.use( require('./middleware/408') ); app.use( require('./middleware/408') );
app.use( require('./middleware/500') ); app.use( require('./middleware/500') );
module.exports = app; module.exports = app;

8
controller/doc.js

@ -1,14 +1,11 @@
var service = { mget: require('../service/mget') }; var service = { mget: require('../service/mget') };
var geojsonify = require('../helper/geojsonify').search; var geojsonify = require('../helper/geojsonify').search;
function setup( backend ){ function setup( backend ){
// allow overriding of dependencies // allow overriding of dependencies
backend = backend || require('../src/backend'); backend = backend || require('../src/backend');
function controller( req, res, next ){ function controller( req, res, next ){
var query = req.clean.ids.map( function(id) { var query = req.clean.ids.map( function(id) {
return { return {
_index: 'pelias', _index: 'pelias',
@ -18,7 +15,6 @@ function setup( backend ){
}); });
service.mget( backend, query, function( err, docs ){ service.mget( backend, query, function( err, docs ){
// error handler // error handler
if( err ){ return next( err ); } if( err ){ return next( err ); }
@ -30,9 +26,7 @@ function setup( backend ){
// respond // respond
return res.status(200).json( geojson ); return res.status(200).json( geojson );
}); });
} }
return controller; return controller;

1
sanitiser/doc.js

@ -1,4 +1,3 @@
var _sanitize = require('../sanitiser/_sanitize'), var _sanitize = require('../sanitiser/_sanitize'),
sanitizers = { sanitizers = {
id: require('../sanitiser/_id'), id: require('../sanitiser/_id'),

2
test/ciao/doc/msuccess.coffee

@ -13,4 +13,4 @@ json.date.should.be.within now-5000, now+5000
#? valid geojson #? valid geojson
json.type.should.equal 'FeatureCollection' json.type.should.equal 'FeatureCollection'
json.features.should.be.instanceof Array json.features.should.be.instanceof Array

2
test/ciao/doc/success.coffee

@ -13,4 +13,4 @@ json.date.should.be.within now-5000, now+5000
#? valid geojson #? valid geojson
json.type.should.equal 'FeatureCollection' json.type.should.equal 'FeatureCollection'
json.features.should.be.instanceof Array json.features.should.be.instanceof Array

5
test/unit/controller/doc.js

@ -1,4 +1,3 @@
var setup = require('../../../controller/doc'), var setup = require('../../../controller/doc'),
mockBackend = require('../mock/backend'); mockBackend = require('../mock/backend');
@ -93,7 +92,7 @@ module.exports.tests.functional_success = function(test, common) {
text: 'test name2, city2, state2' text: 'test name2, city2, state2'
} }
}]; }];
test('functional success (with details)', function(t) { test('functional success (with details)', function(t) {
var backend = mockBackend( 'client/mget/ok/1', function( cmd ){ var backend = mockBackend( 'client/mget/ok/1', function( cmd ){
t.deepEqual(cmd, { body: { docs: [ { _id: 123, _index: 'pelias', _type: 'a' } ] } }, 'correct backend command'); t.deepEqual(cmd, { body: { docs: [ { _id: 123, _index: 'pelias', _type: 'a' } ] } }, 'correct backend command');
@ -141,4 +140,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/run.js

@ -25,4 +25,4 @@ var tests = [
tests.map(function(t) { tests.map(function(t) {
t.all(tape, common); t.all(tape, common);
}); });

10
test/unit/sanitiser/doc.js

@ -7,7 +7,7 @@ var doc = require('../../../sanitiser/doc'),
defaultLengthError = function(input) { return 'invalid param \''+ input + '\': text length, must be >0'; }, defaultLengthError = function(input) { return 'invalid param \''+ input + '\': text length, must be >0'; },
defaultFormatError = 'invalid: must be of the format type:id for ex: \'geoname:4163334\'', defaultFormatError = 'invalid: must be of the format type:id for ex: \'geoname:4163334\'',
defaultError = 'invalid param \'id\': text length, must be >0', defaultError = 'invalid param \'id\': text length, must be >0',
defaultMissingTypeError = function(input) { defaultMissingTypeError = function(input) {
var type = input.split(delimiter)[0]; var type = input.split(delimiter)[0];
return type + ' is invalid. It must be one of these values - [' + indeces.join(', ') + ']'; }, return type + ' is invalid. It must be one of these values - [' + indeces.join(', ') + ']'; },
defaultClean = { ids: [ { id: '123', type: 'geoname' } ], details: true }, defaultClean = { ids: [ { id: '123', type: 'geoname' } ], details: true },
@ -111,7 +111,7 @@ module.exports.tests.sanitize_details = function(test, common) {
t.equal(clean.details, false, 'default details set (to false)'); t.equal(clean.details, false, 'default details set (to false)');
t.end(); t.end();
}); });
}); });
}); });
var valid_values = ['true', true, 1]; var valid_values = ['true', true, 1];
@ -121,7 +121,7 @@ module.exports.tests.sanitize_details = function(test, common) {
t.equal(clean.details, true, 'details set to true'); t.equal(clean.details, true, 'details set to true');
t.end(); t.end();
}); });
}); });
}); });
var valid_false_values = ['false', false, 0]; var valid_false_values = ['false', false, 0];
@ -131,7 +131,7 @@ module.exports.tests.sanitize_details = function(test, common) {
t.equal(clean.details, false, 'details set to false'); t.equal(clean.details, false, 'details set to false');
t.end(); t.end();
}); });
}); });
}); });
test('test default behavior', function(t) { test('test default behavior', function(t) {
@ -196,4 +196,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);
} }
}; };

Loading…
Cancel
Save