|
|
|
@ -1,4 +1,19 @@
|
|
|
|
|
var localNamingConventions = require('../../../middleware/localNamingConventions'); |
|
|
|
|
|
|
|
|
|
var proxyquire = require('proxyquire'); |
|
|
|
|
|
|
|
|
|
var customConfig = { |
|
|
|
|
generate: function generate() { |
|
|
|
|
return { |
|
|
|
|
api : { |
|
|
|
|
localization : { // expand the set of flipped countries
|
|
|
|
|
flipNumberAndStreetCountries : ['NLD'] // Netherlands
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var localNamingConventions = proxyquire('../../../middleware/localNamingConventions', { 'pelias-config': customConfig }); |
|
|
|
|
|
|
|
|
|
module.exports.tests = {}; |
|
|
|
|
|
|
|
|
@ -42,8 +57,28 @@ module.exports.tests.flipNumberAndStreet = function(test, common) {
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var nlAddress = { |
|
|
|
|
'_id': 'test3', |
|
|
|
|
'_type': 'test', |
|
|
|
|
'name': { 'default': '117 Keizersgracht' }, |
|
|
|
|
'center_point': { 'lon': 4.887545, 'lat': 52.376795 }, |
|
|
|
|
'address_parts': { |
|
|
|
|
'zip': '1015', |
|
|
|
|
'number': '117', |
|
|
|
|
'street': 'Keizersgracht' |
|
|
|
|
}, |
|
|
|
|
'parent': { |
|
|
|
|
'region': ['Amsterdam'], |
|
|
|
|
'locality': ['Amsterdam'], |
|
|
|
|
'country_a': ['NLD'], |
|
|
|
|
'county': ['Noord-Holland'], |
|
|
|
|
'country': ['Netherlands'], |
|
|
|
|
'neighbourhood': ['Grachtengordel-West'] |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var req = {}, |
|
|
|
|
res = { data: [ ukAddress, deAddress ] }, |
|
|
|
|
res = { data: [ ukAddress, deAddress, nlAddress ] }, |
|
|
|
|
middleware = localNamingConventions(); |
|
|
|
|
|
|
|
|
|
test('flipNumberAndStreet', function(t) { |
|
|
|
@ -57,6 +92,10 @@ module.exports.tests.flipNumberAndStreet = function(test, common) {
|
|
|
|
|
// eg. '101 Grolmanstraße' -> 'Grolmanstraße 101'
|
|
|
|
|
t.equal( res.data[1].name.default, 'Grolmanstraße 23', 'flipped name' ); |
|
|
|
|
|
|
|
|
|
// NLD address should have the housenumber and street name flipped, too
|
|
|
|
|
// this definition comes from pelias configuration
|
|
|
|
|
t.equal( res.data[2].name.default, 'Keizersgracht 117', 'flipped name' ); |
|
|
|
|
|
|
|
|
|
t.end(); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|