Browse Source

added support for optional country

pull/705/head
Stephen Hess 8 years ago
parent
commit
acb669b7b3
  1. 2
      query/search.js
  2. 18
      test/unit/query/search.js

2
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);

18
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',

Loading…
Cancel
Save