From 040871cbe41c3f0188a7e80662840e9fab9eed1a Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Fri, 4 Sep 2015 17:10:02 -0400 Subject: [PATCH] Whitespace --- sanitiser/reverse.js | 1 - test/unit/query/reverse.js | 6 ++---- test/unit/query/search.js | 31 ++++++++++++++----------------- test/unit/sanitiser/_text.js | 8 ++++---- test/unit/sanitiser/reverse.js | 16 ++++++++-------- test/unit/sanitiser/search.js | 22 +++++++++++----------- 6 files changed, 39 insertions(+), 45 deletions(-) diff --git a/sanitiser/reverse.js b/sanitiser/reverse.js index 780b1c01..74607f3a 100644 --- a/sanitiser/reverse.js +++ b/sanitiser/reverse.js @@ -1,4 +1,3 @@ - var _sanitize = require('../sanitiser/_sanitize'), sanitiser = { latlonzoom: function( req ) { diff --git a/test/unit/query/reverse.js b/test/unit/query/reverse.js index 409f05de..c088bdf9 100644 --- a/test/unit/query/reverse.js +++ b/test/unit/query/reverse.js @@ -1,4 +1,3 @@ - var generate = require('../../../query/reverse'); module.exports.tests = {}; @@ -15,7 +14,7 @@ module.exports.tests.query = function(test, common) { var query = generate({ lat: 29.49136, lon: -82.50622 }); - + var compiled = JSON.parse( JSON.stringify( query ) ); var expected = require('../fixture/reverse_standard'); @@ -38,7 +37,6 @@ module.exports.tests.query = function(test, common) { }; module.exports.all = function (tape, common) { - function test(name, testFunction) { return tape('reverse query ' + name, testFunction); } @@ -46,4 +44,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/query/search.js b/test/unit/query/search.js index e72f8f4d..399fd20a 100644 --- a/test/unit/query/search.js +++ b/test/unit/query/search.js @@ -1,4 +1,3 @@ - var generate = require('../../../query/search'); var parser = require('../../../helper/query_parser'); @@ -19,9 +18,9 @@ module.exports.tests.query = function(test, common) { text: 'test', size: 10, lat: 29.49136, lon: -82.50622, bbox: { - top: 47.47, - right: -61.84, - bottom: 11.51, + top: 47.47, + right: -61.84, + bottom: 11.51, left: -103.16 }, layers: ['test'] @@ -39,9 +38,9 @@ module.exports.tests.query = function(test, common) { var query = generate({ text: 'test', size: 10, bbox: { - top: 47.47, - right: -61.84, - bottom: 11.51, + top: 47.47, + right: -61.84, + bottom: 11.51, left: -103.16 }, layers: ['test'] @@ -50,7 +49,7 @@ module.exports.tests.query = function(test, common) { var compiled = JSON.parse( JSON.stringify( query ) ); var expected = require('../fixture/search_linguistic_bbox'); expected.sort = sort; - + t.deepEqual(compiled, expected, 'valid search query'); t.end(); }); @@ -86,9 +85,9 @@ module.exports.tests.query = function(test, common) { test('valid query with a full valid address', function(t) { var address = '123 main st new york ny 10010 US'; - var query = generate({ text: address, - layers: [ 'geoname', 'osmnode', 'osmway', 'admin0', 'admin1', 'admin2', 'neighborhood', - 'locality', 'local_admin', 'osmaddress', 'openaddresses' ], + var query = generate({ text: address, + layers: [ 'geoname', 'osmnode', 'osmway', 'admin0', 'admin1', 'admin2', 'neighborhood', + 'locality', 'local_admin', 'osmaddress', 'openaddresses' ], size: 10, details: true, parsed_text: parser.get_parsed_address(address), @@ -101,12 +100,12 @@ module.exports.tests.query = function(test, common) { t.deepEqual(compiled, expected, 'valid search query'); t.end(); }); - + test('valid query with partial address', function(t) { var partial_address = 'soho grand, new york'; - var query = generate({ text: partial_address, - layers: [ 'geoname', 'osmnode', 'osmway', 'admin0', 'admin1', 'admin2', 'neighborhood', - 'locality', 'local_admin', 'osmaddress', 'openaddresses' ], + var query = generate({ text: partial_address, + layers: [ 'geoname', 'osmnode', 'osmway', 'admin0', 'admin1', 'admin2', 'neighborhood', + 'locality', 'local_admin', 'osmaddress', 'openaddresses' ], size: 10, details: true, parsed_text: parser.get_parsed_address(partial_address), @@ -137,11 +136,9 @@ module.exports.tests.query = function(test, common) { t.deepEqual(compiled, expected, 'valid search query'); t.end(); }); - }; module.exports.all = function (tape, common) { - function test(name, testFunction) { return tape('search query ' + name, testFunction); } diff --git a/test/unit/sanitiser/_text.js b/test/unit/sanitiser/_text.js index 18d37189..dfb11389 100644 --- a/test/unit/sanitiser/_text.js +++ b/test/unit/sanitiser/_text.js @@ -3,13 +3,13 @@ var text = require('../../../sanitiser/_text'), parser = require('../../../helper/query_parser'), delim = ',', defaultError = 'invalid param \'text\': text length, must be >0', - allLayers = [ 'geoname', 'osmnode', 'osmway', 'admin0', 'admin1', 'admin2', 'neighborhood', + allLayers = [ 'geoname', 'osmnode', 'osmway', 'admin0', 'admin1', 'admin2', 'neighborhood', 'locality', 'local_admin', 'osmaddress', 'openaddresses' ], - nonAddressLayers = [ 'geoname', 'osmnode', 'osmway', 'admin0', 'admin1', 'admin2', 'neighborhood', + nonAddressLayers = [ 'geoname', 'osmnode', 'osmway', 'admin0', 'admin1', 'admin2', 'neighborhood', 'locality', 'local_admin' ], defaultParsed= { }, - defaultClean = { text: 'test', - layers: allLayers, + defaultClean = { text: 'test', + layers: allLayers, size: 10, details: true, parsed_text: defaultParsed, diff --git a/test/unit/sanitiser/reverse.js b/test/unit/sanitiser/reverse.js index 559f3cea..cea1f913 100644 --- a/test/unit/sanitiser/reverse.js +++ b/test/unit/sanitiser/reverse.js @@ -35,7 +35,7 @@ module.exports.tests.sanitize_lat = function(test, common) { valid: [ 0, 45, 90, -0, '0', '45', '90', -181, -120, -91, 91, 120, 181 ], missing: ['', undefined, null] }; - test('invalid lat', function(t) { + test('invalid lat', function(t) { lats.invalid.forEach( function( lat ){ sanitize({ lat: lat, lon: 0 }, function( err, clean ){ t.equal(err, 'invalid param \'lat\': must be >-90 and <90', lat + ' is an invalid latitude'); @@ -44,7 +44,7 @@ module.exports.tests.sanitize_lat = function(test, common) { }); t.end(); }); - test('valid lat', function(t) { + test('valid lat', function(t) { lats.valid.forEach( function( lat ){ sanitize({ lat: lat, lon: 0 }, function( err, clean ){ var expected = JSON.parse(JSON.stringify( defaultClean )); @@ -55,7 +55,7 @@ module.exports.tests.sanitize_lat = function(test, common) { }); t.end(); }); - test('missing lat', function(t) { + test('missing lat', function(t) { lats.missing.forEach( function( lat ){ sanitize({ lat: lat, lon: 0 }, function( err, clean ){ t.equal(err, 'missing param \'lat\'', 'latitude is a required field'); @@ -71,7 +71,7 @@ module.exports.tests.sanitize_lon = function(test, common) { valid: [ -360, -181, 181, -180, -1, -0, 0, 45, 90, '-180', '0', '180' ], missing: ['', undefined, null] }; - test('valid lon', function(t) { + test('valid lon', function(t) { lons.valid.forEach( function( lon ){ sanitize({ lat: 0, lon: lon }, function( err, clean ){ var expected = JSON.parse(JSON.stringify( defaultClean )); @@ -82,7 +82,7 @@ module.exports.tests.sanitize_lon = function(test, common) { }); t.end(); }); - test('missing lon', function(t) { + test('missing lon', function(t) { lons.missing.forEach( function( lon ){ sanitize({ lat: 0, lon: lon }, function( err, clean ){ t.equal(err, 'missing param \'lon\'', 'longitude is a required field'); @@ -123,7 +123,7 @@ module.exports.tests.sanitize_details = function(test, common) { t.equal(clean.details, false, 'details set to false'); t.end(); }); - }); + }); }); var valid_values = [true, 'true', 1, '1', 'yes', 'y']; @@ -133,7 +133,7 @@ module.exports.tests.sanitize_details = function(test, common) { t.equal(clean.details, true, 'details set to true'); t.end(); }); - }); + }); }); test('test default behavior', function(t) { @@ -150,7 +150,7 @@ module.exports.tests.sanitize_details = function(test, common) { t.equal(clean.details, false, 'details set to false'); t.end(); }); - }); + }); }); }; diff --git a/test/unit/sanitiser/search.js b/test/unit/sanitiser/search.js index d0c20f18..868200e5 100644 --- a/test/unit/sanitiser/search.js +++ b/test/unit/sanitiser/search.js @@ -7,7 +7,7 @@ var search = require('../../../sanitiser/search'), middleware = search.middleware, delim = ',', defaultError = 'invalid param \'text\': text length, must be >0', - defaultClean = { text: 'test', + defaultClean = { text: 'test', types: { }, size: 10, @@ -32,7 +32,7 @@ module.exports.tests.interface = function(test, common) { }; module.exports.tests.sanitize_invalid_text = function(test, common) { - test('invalid text', function(t) { + test('invalid text', function(t) { var invalid = [ '', 100, null, undefined, new Date() ]; invalid.forEach( function( text ){ sanitize({ text: text }, function( err, clean ){ @@ -91,7 +91,7 @@ module.exports.tests.sanitize_lat = function(test, common) { invalid: [], valid: [ 0, 45, 90, -0, '0', '45', '90', -181, -120, -91, 91, 120, 181 ] }; - test('invalid lat', function(t) { + test('invalid lat', function(t) { lats.invalid.forEach( function( lat ){ sanitize({ text: 'test', lat: lat, lon: 0 }, function( err, clean ){ t.equal(err, 'invalid param \'lat\': must be >-90 and <90', lat + ' is an invalid latitude'); @@ -100,7 +100,7 @@ module.exports.tests.sanitize_lat = function(test, common) { }); t.end(); }); - test('valid lat', function(t) { + test('valid lat', function(t) { lats.valid.forEach( function( lat ){ sanitize({ text: 'test', lat: lat, lon: 0 }, function( err, clean ){ var expected = JSON.parse(JSON.stringify( defaultClean )); @@ -117,7 +117,7 @@ module.exports.tests.sanitize_lon = function(test, common) { var lons = { valid: [ -381, -181, -180, -1, -0, 0, 45, 90, '-180', '0', '180', 181 ] }; - test('valid lon', function(t) { + test('valid lon', function(t) { lons.valid.forEach( function( lon ){ sanitize({ text: 'test', lat: 0, lon: lon }, function( err, clean ){ var expected = JSON.parse(JSON.stringify( defaultClean )); @@ -183,9 +183,9 @@ module.exports.tests.sanitize_bbox = function(test, common) { '91, -181,-91,11', '91, -11,-91,181' ] - + }; - test('invalid bbox', function(t) { + test('invalid bbox', function(t) { bboxes.invalid.forEach( function( bbox ){ sanitize({ text: 'test', bbox: bbox }, function( err, clean ){ t.equal(err, undefined, 'no error'); @@ -194,7 +194,7 @@ module.exports.tests.sanitize_bbox = function(test, common) { }); t.end(); }); - test('valid bbox', function(t) { + test('valid bbox', function(t) { bboxes.valid.forEach( function( bbox ){ sanitize({ text: 'test', bbox: bbox }, function( err, clean ){ var bboxArray = bbox.split(',').map(function(i) { @@ -264,7 +264,7 @@ module.exports.tests.sanitize_details = function(test, common) { t.equal(clean.details, false, 'default details set (to false)'); t.end(); }); - }); + }); }); var valid_values = ['true', true, 1, '1', 'yes', 'y']; @@ -274,7 +274,7 @@ module.exports.tests.sanitize_details = function(test, common) { t.equal(clean.details, true, 'details set to true'); t.end(); }); - }); + }); }); var valid_false_values = ['false', false, 0, '0', 'no', 'n']; @@ -284,7 +284,7 @@ module.exports.tests.sanitize_details = function(test, common) { t.equal(clean.details, false, 'details set to false'); t.end(); }); - }); + }); }); test('test default behavior', function(t) {