|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
var generate = require('../../../query/component_geocoding'); |
|
|
|
|
var generate = require('../../../query/structured_geocoding'); |
|
|
|
|
var fs = require('fs'); |
|
|
|
|
|
|
|
|
|
module.exports.tests = {}; |
|
|
|
@ -14,7 +14,6 @@ module.exports.tests.query = function(test, common) {
|
|
|
|
|
test('valid search + focus + bbox', function(t) { |
|
|
|
|
var clean = { |
|
|
|
|
parsed_text: { |
|
|
|
|
street: 'street value' |
|
|
|
|
}, |
|
|
|
|
text: 'test', |
|
|
|
|
querySize: 10, |
|
|
|
@ -29,7 +28,7 @@ module.exports.tests.query = function(test, common) {
|
|
|
|
|
var query = generate(clean); |
|
|
|
|
|
|
|
|
|
var compiled = JSON.parse( JSON.stringify( query ) ); |
|
|
|
|
var expected = require('../fixture/component_geocoding/linguistic_focus_bbox'); |
|
|
|
|
var expected = require('../fixture/structured_geocoding/linguistic_focus_bbox'); |
|
|
|
|
|
|
|
|
|
t.deepEqual(compiled.type, 'fallback', 'query type set'); |
|
|
|
|
t.deepEqual(compiled.body, expected, 'search_linguistic_focus_bbox'); |
|
|
|
@ -39,7 +38,6 @@ module.exports.tests.query = function(test, common) {
|
|
|
|
|
test('valid search + bbox', function(t) { |
|
|
|
|
var clean = { |
|
|
|
|
parsed_text: { |
|
|
|
|
street: 'street value' |
|
|
|
|
}, |
|
|
|
|
text: 'test', |
|
|
|
|
querySize: 10, |
|
|
|
@ -53,7 +51,7 @@ module.exports.tests.query = function(test, common) {
|
|
|
|
|
var query = generate(clean); |
|
|
|
|
|
|
|
|
|
var compiled = JSON.parse( JSON.stringify( query ) ); |
|
|
|
|
var expected = require('../fixture/component_geocoding/linguistic_bbox'); |
|
|
|
|
var expected = require('../fixture/structured_geocoding/linguistic_bbox'); |
|
|
|
|
|
|
|
|
|
t.deepEqual(compiled.type, 'fallback', 'query type set'); |
|
|
|
|
t.deepEqual(compiled.body, expected, 'search_linguistic_bbox'); |
|
|
|
@ -63,7 +61,6 @@ module.exports.tests.query = function(test, common) {
|
|
|
|
|
test('valid lingustic-only search', function(t) { |
|
|
|
|
var clean = { |
|
|
|
|
parsed_text: { |
|
|
|
|
street: 'street value' |
|
|
|
|
}, |
|
|
|
|
text: 'test', querySize: 10, |
|
|
|
|
layers: ['test'] |
|
|
|
@ -72,7 +69,7 @@ module.exports.tests.query = function(test, common) {
|
|
|
|
|
var query = generate(clean); |
|
|
|
|
|
|
|
|
|
var compiled = JSON.parse( JSON.stringify( query ) ); |
|
|
|
|
var expected = require('../fixture/component_geocoding/linguistic_only'); |
|
|
|
|
var expected = require('../fixture/structured_geocoding/linguistic_only'); |
|
|
|
|
|
|
|
|
|
t.deepEqual(compiled.type, 'fallback', 'query type set'); |
|
|
|
|
t.deepEqual(compiled.body, expected, 'search_linguistic_only'); |
|
|
|
@ -82,7 +79,6 @@ module.exports.tests.query = function(test, common) {
|
|
|
|
|
test('search search + focus', function(t) { |
|
|
|
|
var clean = { |
|
|
|
|
parsed_text: { |
|
|
|
|
street: 'street value' |
|
|
|
|
}, |
|
|
|
|
text: 'test', querySize: 10, |
|
|
|
|
'focus.point.lat': 29.49136, 'focus.point.lon': -82.50622, |
|
|
|
@ -92,7 +88,7 @@ module.exports.tests.query = function(test, common) {
|
|
|
|
|
var query = generate(clean); |
|
|
|
|
|
|
|
|
|
var compiled = JSON.parse( JSON.stringify( query ) ); |
|
|
|
|
var expected = require('../fixture/component_geocoding/linguistic_focus'); |
|
|
|
|
var expected = require('../fixture/structured_geocoding/linguistic_focus'); |
|
|
|
|
|
|
|
|
|
t.deepEqual(compiled.type, 'fallback', 'query type set'); |
|
|
|
|
t.deepEqual(compiled.body, expected, 'search_linguistic_focus'); |
|
|
|
@ -102,7 +98,6 @@ module.exports.tests.query = function(test, common) {
|
|
|
|
|
test('search search + viewport', function(t) { |
|
|
|
|
var clean = { |
|
|
|
|
parsed_text: { |
|
|
|
|
street: 'street value' |
|
|
|
|
}, |
|
|
|
|
text: 'test', querySize: 10, |
|
|
|
|
'focus.viewport.min_lat': 28.49136, |
|
|
|
@ -115,7 +110,7 @@ module.exports.tests.query = function(test, common) {
|
|
|
|
|
var query = generate(clean); |
|
|
|
|
|
|
|
|
|
var compiled = JSON.parse( JSON.stringify( query ) ); |
|
|
|
|
var expected = require('../fixture/component_geocoding/linguistic_viewport'); |
|
|
|
|
var expected = require('../fixture/structured_geocoding/linguistic_viewport'); |
|
|
|
|
|
|
|
|
|
t.deepEqual(compiled.type, 'fallback', 'query type set'); |
|
|
|
|
t.deepEqual(compiled.body, expected, 'search_linguistic_viewport'); |
|
|
|
@ -127,7 +122,6 @@ module.exports.tests.query = function(test, common) {
|
|
|
|
|
test('search with viewport diagonal < 1km should set scale to 1km', function(t) { |
|
|
|
|
var clean = { |
|
|
|
|
parsed_text: { |
|
|
|
|
street: 'street value' |
|
|
|
|
}, |
|
|
|
|
text: 'test', querySize: 10, |
|
|
|
|
'focus.viewport.min_lat': 28.49135, |
|
|
|
@ -140,7 +134,7 @@ module.exports.tests.query = function(test, common) {
|
|
|
|
|
var query = generate(clean); |
|
|
|
|
|
|
|
|
|
var compiled = JSON.parse( JSON.stringify( query ) ); |
|
|
|
|
var expected = require('../fixture/component_geocoding/linguistic_viewport_min_diagonal'); |
|
|
|
|
var expected = require('../fixture/structured_geocoding/linguistic_viewport_min_diagonal'); |
|
|
|
|
|
|
|
|
|
t.deepEqual(compiled.type, 'fallback', 'query type set'); |
|
|
|
|
t.deepEqual(compiled.body, expected, 'valid search query'); |
|
|
|
@ -150,7 +144,6 @@ module.exports.tests.query = function(test, common) {
|
|
|
|
|
test('search search + focus on null island', function(t) { |
|
|
|
|
var clean = { |
|
|
|
|
parsed_text: { |
|
|
|
|
street: 'street value' |
|
|
|
|
}, |
|
|
|
|
text: 'test', querySize: 10, |
|
|
|
|
'focus.point.lat': 0, 'focus.point.lon': 0, |
|
|
|
@ -160,7 +153,7 @@ module.exports.tests.query = function(test, common) {
|
|
|
|
|
var query = generate(clean); |
|
|
|
|
|
|
|
|
|
var compiled = JSON.parse( JSON.stringify( query ) ); |
|
|
|
|
var expected = require('../fixture/component_geocoding/linguistic_focus_null_island'); |
|
|
|
|
var expected = require('../fixture/structured_geocoding/linguistic_focus_null_island'); |
|
|
|
|
|
|
|
|
|
t.deepEqual(compiled.type, 'fallback', 'query type set'); |
|
|
|
|
t.deepEqual(compiled.body, expected, 'search_linguistic_focus_null_island'); |
|
|
|
@ -187,7 +180,7 @@ module.exports.tests.query = function(test, common) {
|
|
|
|
|
var query = generate(clean); |
|
|
|
|
|
|
|
|
|
var compiled = JSON.parse(JSON.stringify(query)); |
|
|
|
|
var expected = require('../fixture/component_geocoding/fallback'); |
|
|
|
|
var expected = require('../fixture/structured_geocoding/fallback'); |
|
|
|
|
|
|
|
|
|
t.deepEqual(compiled.type, 'fallback', 'query type set'); |
|
|
|
|
t.deepEqual(compiled.body, expected, 'fallbackQuery'); |
|
|
|
@ -198,7 +191,6 @@ module.exports.tests.query = function(test, common) {
|
|
|
|
|
test('valid boundary.country search', function(t) { |
|
|
|
|
var clean = { |
|
|
|
|
parsed_text: { |
|
|
|
|
street: 'street value' |
|
|
|
|
}, |
|
|
|
|
text: 'test', querySize: 10, |
|
|
|
|
layers: ['test'], |
|
|
|
@ -208,7 +200,7 @@ module.exports.tests.query = function(test, common) {
|
|
|
|
|
var query = generate(clean); |
|
|
|
|
|
|
|
|
|
var compiled = JSON.parse( JSON.stringify( query ) ); |
|
|
|
|
var expected = require('../fixture/component_geocoding/boundary_country'); |
|
|
|
|
var expected = require('../fixture/structured_geocoding/boundary_country'); |
|
|
|
|
|
|
|
|
|
t.deepEqual(compiled.type, 'fallback', 'query type set'); |
|
|
|
|
t.deepEqual(compiled.body, expected, 'search: valid boundary.country query'); |
|
|
|
@ -218,7 +210,6 @@ module.exports.tests.query = function(test, common) {
|
|
|
|
|
test('valid sources filter', function(t) { |
|
|
|
|
var clean = { |
|
|
|
|
parsed_text: { |
|
|
|
|
street: 'street value' |
|
|
|
|
}, |
|
|
|
|
'text': 'test', |
|
|
|
|
'sources': ['test_source'] |
|
|
|
@ -227,7 +218,7 @@ module.exports.tests.query = function(test, common) {
|
|
|
|
|
var query = generate(clean); |
|
|
|
|
|
|
|
|
|
var compiled = JSON.parse( JSON.stringify( query ) ); |
|
|
|
|
var expected = require('../fixture/component_geocoding/with_source_filtering'); |
|
|
|
|
var expected = require('../fixture/structured_geocoding/with_source_filtering'); |
|
|
|
|
|
|
|
|
|
t.deepEqual(compiled.type, 'fallback', 'query type set'); |
|
|
|
|
t.deepEqual(compiled.body, expected, 'search: valid search query with source filtering'); |
|
|
|
@ -238,7 +229,7 @@ module.exports.tests.query = function(test, common) {
|
|
|
|
|
|
|
|
|
|
module.exports.all = function (tape, common) { |
|
|
|
|
function test(name, testFunction) { |
|
|
|
|
return tape('component_geocoding query ' + name, testFunction); |
|
|
|
|
return tape('structured_geocoding query ' + name, testFunction); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for( var testCase in module.exports.tests ){ |