From acb669b7b3871dfa85784a86f9c4f7f62316fdc7 Mon Sep 17 00:00:00 2001 From: Stephen Hess Date: Tue, 25 Oct 2016 12:36:48 -0400 Subject: [PATCH] added support for optional country --- query/search.js | 2 +- test/unit/query/search.js | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/query/search.js b/query/search.js index c62b04d7..4f9b1c73 100644 --- a/query/search.js +++ b/query/search.js @@ -144,7 +144,7 @@ function isCityStateOnly(vs) { var allowedFields = ['locality', 'region']; var disallowedFields = ['query', 'category', 'housenumber', 'street', - 'neighbourhood', 'borough', 'postcode', 'county', 'country']; + 'neighbourhood', 'borough', 'postcode', 'county']; return allowedFields.every(isSet) && !disallowedFields.some(isSet); diff --git a/test/unit/query/search.js b/test/unit/query/search.js index eae7e40a..1aae8df6 100644 --- a/test/unit/query/search.js +++ b/test/unit/query/search.js @@ -289,6 +289,22 @@ module.exports.tests.city_state = function(test, common) { }); + test('only city, state, and country set should return query', function(t) { + var clean = { + parsed_text: { + 'city': 'city value', + 'state': 'state value', + 'country': 'country value' + } + }; + + var query = generate(clean); + + t.notEqual(query, undefined, 'should not have returned undefined'); + t.end(); + + }); + test('city- OR state-only should return undefined', function(t) { ['city', 'state'].forEach(function(placeType) { var clean = { @@ -308,7 +324,7 @@ module.exports.tests.city_state = function(test, common) { }); test('city and state with at least one other input: field should return undefined', function(t) { - ['query', 'category', 'number', 'neighbourhood', 'borough', 'postalcode', 'county', 'country'].forEach(function(placeType) { + ['query', 'category', 'number', 'neighbourhood', 'borough', 'postalcode', 'county'].forEach(function(placeType) { var clean = { parsed_text: { 'city': 'city value',