diff --git a/query/autocomplete.js b/query/autocomplete.js index 0d235b0f..b3328a69 100644 --- a/query/autocomplete.js +++ b/query/autocomplete.js @@ -37,10 +37,7 @@ function generateQuery( clean ){ }); } - var result = query.render( vs ); - - // @todo: remove this hack - return JSON.parse( JSON.stringify( result ) ); + return query.render( vs ); } module.exports = generateQuery; diff --git a/query/reverse.js b/query/reverse.js index 4e8b13c5..bcf24755 100644 --- a/query/reverse.js +++ b/query/reverse.js @@ -43,10 +43,7 @@ function generateQuery( clean ){ }); } - var result = query.render( vs ); - - // @todo: remove this hack - return JSON.parse( JSON.stringify( result ) ); + return query.render( vs ); } module.exports = generateQuery; diff --git a/query/search.js b/query/search.js index bd864474..a0b65721 100644 --- a/query/search.js +++ b/query/search.js @@ -187,8 +187,7 @@ function generateQuery( clean ){ // @todo: remove unnessesary sort conditions result.sort = result.sort.concat( sort( clean ) ); - // @todo: remove this hack - return JSON.parse( JSON.stringify( result ) ); + return result; } module.exports = generateQuery; diff --git a/test/unit/query/autocomplete.js b/test/unit/query/autocomplete.js index 5b69c8de..1167c17b 100644 --- a/test/unit/query/autocomplete.js +++ b/test/unit/query/autocomplete.js @@ -10,13 +10,6 @@ module.exports.tests.interface = function(test, common) { t.end(); }); }; -function foo( a, b ){ - console.log( '----------------' ); - console.log( JSON.stringify( a, null, 2 ) ); - console.log( '----------------' ); - console.log( JSON.stringify( b, null, 2 ) ); - console.log( '----------------' ); -} module.exports.tests.query = function(test, common) { test('valid lingustic-only autocomplete', function(t) { @@ -24,9 +17,10 @@ module.exports.tests.query = function(test, common) { text: 'test' }); + var compiled = JSON.parse( JSON.stringify( query ) ); var expected = require('../fixture/autocomplete_linguistic_only'); - t.deepEqual(query, expected, 'valid autocomplete query'); + t.deepEqual(compiled, expected, 'valid autocomplete query'); t.end(); }); @@ -37,9 +31,10 @@ module.exports.tests.query = function(test, common) { lon: -82.50622 }); + var compiled = JSON.parse( JSON.stringify( query ) ); var expected = require('../fixture/autocomplete_linguistic_focus'); - t.deepEqual(query, expected, 'valid autocomplete query'); + t.deepEqual(compiled, expected, 'valid autocomplete query'); t.end(); }); }; diff --git a/test/unit/query/reverse.js b/test/unit/query/reverse.js index a8dde064..409f05de 100644 --- a/test/unit/query/reverse.js +++ b/test/unit/query/reverse.js @@ -3,14 +3,6 @@ var generate = require('../../../query/reverse'); module.exports.tests = {}; -function debug( a,b ){ - console.log( '----------------------' ); - console.log( JSON.stringify( a, null, 2 ) ); - console.log( '----------------------' ); - console.log( JSON.stringify( b, null, 2 ) ); - console.log( '----------------------' ); -} - module.exports.tests.interface = function(test, common) { test('valid interface', function(t) { t.equal(typeof generate, 'function', 'valid function'); @@ -24,8 +16,10 @@ module.exports.tests.query = function(test, common) { lat: 29.49136, lon: -82.50622 }); + var compiled = JSON.parse( JSON.stringify( query ) ); var expected = require('../fixture/reverse_standard'); - t.deepEqual(query, expected, 'valid reverse query'); + + t.deepEqual(compiled, expected, 'valid reverse query'); t.end(); }); test('size fuzz test', function(t) { @@ -36,7 +30,8 @@ module.exports.tests.query = function(test, common) { lat: 29.49136, lon: -82.50622, size: size }); - t.equal( query.size, size ? size : 1, 'valid reverse query for size: '+ size); + var compiled = JSON.parse( JSON.stringify( query ) ); + t.equal( compiled.size, size ? size : 1, 'valid reverse query for size: '+ size); }); t.end(); }); diff --git a/test/unit/query/search.js b/test/unit/query/search.js index e4f70b9a..e72f8f4d 100644 --- a/test/unit/query/search.js +++ b/test/unit/query/search.js @@ -27,10 +27,11 @@ module.exports.tests.query = function(test, common) { layers: ['test'] }); + var compiled = JSON.parse( JSON.stringify( query ) ); var expected = require('../fixture/search_linguistic_focus_bbox'); expected.sort = sort; - t.deepEqual(query, expected, 'valid search query'); + t.deepEqual(compiled, expected, 'valid search query'); t.end(); }); @@ -46,10 +47,11 @@ module.exports.tests.query = function(test, common) { layers: ['test'] }); + var compiled = JSON.parse( JSON.stringify( query ) ); var expected = require('../fixture/search_linguistic_bbox'); expected.sort = sort; - t.deepEqual(query, expected, 'valid search query'); + t.deepEqual(compiled, expected, 'valid search query'); t.end(); }); @@ -59,10 +61,11 @@ module.exports.tests.query = function(test, common) { layers: ['test'] }); + var compiled = JSON.parse( JSON.stringify( query ) ); var expected = require('../fixture/search_linguistic_only'); expected.sort = sort; - t.deepEqual(query, expected, 'valid search query'); + t.deepEqual(compiled, expected, 'valid search query'); t.end(); }); @@ -73,10 +76,11 @@ module.exports.tests.query = function(test, common) { layers: ['test'] }); + var compiled = JSON.parse( JSON.stringify( query ) ); var expected = require('../fixture/search_linguistic_focus'); expected.sort = sort; - t.deepEqual(query, expected, 'valid search query'); + t.deepEqual(compiled, expected, 'valid search query'); t.end(); }); @@ -90,10 +94,11 @@ module.exports.tests.query = function(test, common) { parsed_text: parser.get_parsed_address(address), }); + var compiled = JSON.parse( JSON.stringify( query ) ); var expected = require('../fixture/search_full_address'); expected.sort = sort; - t.deepEqual(query, expected, 'valid search query'); + t.deepEqual(compiled, expected, 'valid search query'); t.end(); }); @@ -107,10 +112,11 @@ module.exports.tests.query = function(test, common) { parsed_text: parser.get_parsed_address(partial_address), }); + var compiled = JSON.parse( JSON.stringify( query ) ); var expected = require('../fixture/search_partial_address'); expected.sort = sort; - t.deepEqual(query, expected, 'valid search query'); + t.deepEqual(compiled, expected, 'valid search query'); t.end(); }); @@ -124,10 +130,11 @@ module.exports.tests.query = function(test, common) { parsed_text: parser.get_parsed_address(partial_address), }); + var compiled = JSON.parse( JSON.stringify( query ) ); var expected = require('../fixture/search_regions_address'); expected.sort = sort; - t.deepEqual(query, expected, 'valid search query'); + t.deepEqual(compiled, expected, 'valid search query'); t.end(); });