diff --git a/query/address_search_using_ids.js b/query/address_search_using_ids.js index 9dbf1633..e3a5aea5 100644 --- a/query/address_search_using_ids.js +++ b/query/address_search_using_ids.js @@ -66,10 +66,8 @@ addressUsingIdsQuery.filter( peliasQuery.view.sources ); // if there are region/macroregion layers, return ['region', 'macroregion'] const granularity_bands = [ - ['neighbourhood', 'borough', 'locality', 'localadmin'], - ['county', 'macrocounty'], - ['region', 'macroregion'], - ['dependency', 'country'] + ['neighbourhood', 'borough', 'locality', 'localadmin', 'region', 'macroregion', 'dependency', 'country'], + ['county', 'macrocounty'] ]; function anyResultsAtGranularityBand(results, band) { diff --git a/test/unit/query/address_search_using_ids.js b/test/unit/query/address_search_using_ids.js index 2e687dbd..05fffae7 100644 --- a/test/unit/query/address_search_using_ids.js +++ b/test/unit/query/address_search_using_ids.js @@ -179,119 +179,64 @@ module.exports.tests.granularity_bands = (test, common) => { source_id: 5 }, { - layer: 'neighbourhood', + layer: 'macrocounty', source_id: 6 }, { - layer: 'borough', + layer: 'region', source_id: 7 }, { - layer: 'locality', + layer: 'macroregion', source_id: 8 }, { - layer: 'localadmin', + layer: 'dependency', source_id: 9 - } - ] - }; - - const generateQuery = proxyquire('../../../query/address_search_using_ids', { - 'pelias-logger': logger, - 'pelias-query': { - layout: { - AddressesUsingIdsQuery: MockQuery }, - view: views, - Vars: require('pelias-query').Vars - } - - }); - - const generatedQuery = generateQuery(clean, res); - - t.deepEquals(JSON.parse(generatedQuery.body.vs.var('input:layers')), { - neighbourhood: [1, 6], - borough: [2, 7], - locality: [3, 8], - localadmin: [4, 9] - }); - - t.end(); - }); - - test('only band members with ids should be passed', (t) => { - const logger = mock_logger(); - - const clean = { - parsed_text: { - number: 'housenumber value', - street: 'street value' - } - }; - const res = { - data: [ + { + layer: 'country', + source_id: 10 + }, { layer: 'neighbourhood', - source_id: 1 - } - ] - }; - - const generateQuery = proxyquire('../../../query/address_search_using_ids', { - 'pelias-logger': logger, - 'pelias-query': { - layout: { - AddressesUsingIdsQuery: MockQuery + source_id: 11 + }, + { + layer: 'borough', + source_id: 12 + }, + { + layer: 'locality', + source_id: 13 + }, + { + layer: 'localadmin', + source_id: 14 }, - view: views, - Vars: require('pelias-query').Vars - } - }); - - const generatedQuery = generateQuery(clean, res); - - t.deepEquals(JSON.parse(generatedQuery.body.vs.var('input:layers')), { - neighbourhood: [1], - borough: [], - locality: [], - localadmin: [] - }); - - t.end(); - }); - - test('county/macrocounty granularity band', (t) => { - const logger = mock_logger(); - - const clean = { - parsed_text: { - number: 'housenumber value', - street: 'street value' - } - }; - const res = { - data: [ { layer: 'county', - source_id: 1 + source_id: 15 }, { layer: 'macrocounty', - source_id: 2 + source_id: 16 }, { layer: 'region', - source_id: 3 + source_id: 17 }, { - layer: 'county', - source_id: 4 + layer: 'macroregion', + source_id: 18 }, { - layer: 'macrocounty', - source_id: 5 + layer: 'dependency', + source_id: 19 + }, + { + layer: 'country', + source_id: 20 } ] }; @@ -311,14 +256,20 @@ module.exports.tests.granularity_bands = (test, common) => { const generatedQuery = generateQuery(clean, res); t.deepEquals(JSON.parse(generatedQuery.body.vs.var('input:layers')), { - county: [1, 4], - macrocounty: [2, 5] + neighbourhood: [1, 11], + borough: [2, 12], + locality: [3, 13], + localadmin: [4, 14], + region: [7, 17], + macroregion: [8, 18], + dependency: [9, 19], + country: [10, 20] }); t.end(); }); - test('region/macroregion granularity band', (t) => { + test('only band members with ids should be passed', (t) => { const logger = mock_logger(); const clean = { @@ -330,24 +281,8 @@ module.exports.tests.granularity_bands = (test, common) => { const res = { data: [ { - layer: 'region', + layer: 'neighbourhood', source_id: 1 - }, - { - layer: 'macroregion', - source_id: 2 - }, - { - layer: 'country', - source_id: 3 - }, - { - layer: 'region', - source_id: 4 - }, - { - layer: 'macroregion', - source_id: 5 } ] }; @@ -361,21 +296,25 @@ module.exports.tests.granularity_bands = (test, common) => { view: views, Vars: require('pelias-query').Vars } - }); const generatedQuery = generateQuery(clean, res); t.deepEquals(JSON.parse(generatedQuery.body.vs.var('input:layers')), { - region: [1, 4], - macroregion: [2, 5] + neighbourhood: [1], + borough: [], + locality: [], + localadmin: [], + region: [], + macroregion: [], + dependency: [], + country: [] }); t.end(); - }); - test('dependency/country granularity band', (t) => { + test('county/macrocounty granularity band', (t) => { const logger = mock_logger(); const clean = { @@ -387,20 +326,20 @@ module.exports.tests.granularity_bands = (test, common) => { const res = { data: [ { - layer: 'dependency', + layer: 'county', source_id: 1 }, { - layer: 'country', + layer: 'macrocounty', source_id: 2 }, { - layer: 'dependency', - source_id: 3 + layer: 'county', + source_id: 4 }, { - layer: 'country', - source_id: 4 + layer: 'macrocounty', + source_id: 5 } ] }; @@ -420,12 +359,11 @@ module.exports.tests.granularity_bands = (test, common) => { const generatedQuery = generateQuery(clean, res); t.deepEquals(JSON.parse(generatedQuery.body.vs.var('input:layers')), { - dependency: [1, 3], - country: [2, 4] + county: [1, 4], + macrocounty: [2, 5] }); t.end(); - }); };