|
|
@ -21,6 +21,7 @@ module.exports.tests.trimByGranularity = function(test, common) { |
|
|
|
{ name: 'venue 2', _matched_queries: ['fallback.venue'] }, |
|
|
|
{ name: 'venue 2', _matched_queries: ['fallback.venue'] }, |
|
|
|
{ name: 'address 1', _matched_queries: ['fallback.address'] }, |
|
|
|
{ name: 'address 1', _matched_queries: ['fallback.address'] }, |
|
|
|
{ name: 'street 1', _matched_queries: ['fallback.street'] }, |
|
|
|
{ name: 'street 1', _matched_queries: ['fallback.street'] }, |
|
|
|
|
|
|
|
{ name: 'postalcode 1', _matched_queries: ['fallback.postalcode'] }, |
|
|
|
{ name: 'neighbourhood 1', _matched_queries: ['fallback.neighbourhood'] }, |
|
|
|
{ name: 'neighbourhood 1', _matched_queries: ['fallback.neighbourhood'] }, |
|
|
|
{ name: 'borough 1', _matched_queries: ['fallback.borough'] }, |
|
|
|
{ name: 'borough 1', _matched_queries: ['fallback.borough'] }, |
|
|
|
{ name: 'locality 1', _matched_queries: ['fallback.locality'] }, |
|
|
|
{ name: 'locality 1', _matched_queries: ['fallback.locality'] }, |
|
|
@ -58,6 +59,7 @@ module.exports.tests.trimByGranularity = function(test, common) { |
|
|
|
{ name: 'address 1', _matched_queries: ['fallback.address'] }, |
|
|
|
{ name: 'address 1', _matched_queries: ['fallback.address'] }, |
|
|
|
{ name: 'address 2', _matched_queries: ['fallback.address'] }, |
|
|
|
{ name: 'address 2', _matched_queries: ['fallback.address'] }, |
|
|
|
{ name: 'street 1', _matched_queries: ['fallback.street'] }, |
|
|
|
{ name: 'street 1', _matched_queries: ['fallback.street'] }, |
|
|
|
|
|
|
|
{ name: 'postalcode 1', _matched_queries: ['fallback.postalcode'] }, |
|
|
|
{ name: 'neighbourhood 1', _matched_queries: ['fallback.neighbourhood'] }, |
|
|
|
{ name: 'neighbourhood 1', _matched_queries: ['fallback.neighbourhood'] }, |
|
|
|
{ name: 'borough 1', _matched_queries: ['fallback.borough'] }, |
|
|
|
{ name: 'borough 1', _matched_queries: ['fallback.borough'] }, |
|
|
|
{ name: 'locality 1', _matched_queries: ['fallback.locality'] }, |
|
|
|
{ name: 'locality 1', _matched_queries: ['fallback.locality'] }, |
|
|
@ -94,6 +96,7 @@ module.exports.tests.trimByGranularity = function(test, common) { |
|
|
|
data: [ |
|
|
|
data: [ |
|
|
|
{ name: 'street 1', _matched_queries: ['fallback.street'] }, |
|
|
|
{ name: 'street 1', _matched_queries: ['fallback.street'] }, |
|
|
|
{ name: 'street 2', _matched_queries: ['fallback.street'] }, |
|
|
|
{ name: 'street 2', _matched_queries: ['fallback.street'] }, |
|
|
|
|
|
|
|
{ name: 'postalcode 1', _matched_queries: ['fallback.postalcode'] }, |
|
|
|
{ name: 'neighbourhood 1', _matched_queries: ['fallback.neighbourhood'] }, |
|
|
|
{ name: 'neighbourhood 1', _matched_queries: ['fallback.neighbourhood'] }, |
|
|
|
{ name: 'borough 1', _matched_queries: ['fallback.borough'] }, |
|
|
|
{ name: 'borough 1', _matched_queries: ['fallback.borough'] }, |
|
|
|
{ name: 'locality 1', _matched_queries: ['fallback.locality'] }, |
|
|
|
{ name: 'locality 1', _matched_queries: ['fallback.locality'] }, |
|
|
@ -123,6 +126,49 @@ module.exports.tests.trimByGranularity = function(test, common) { |
|
|
|
testIt(); |
|
|
|
testIt(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test('all records with fallback.* matched_queries name should retain only postalcodes when they are most granular', function(t) { |
|
|
|
|
|
|
|
var req = { |
|
|
|
|
|
|
|
clean: { |
|
|
|
|
|
|
|
parsed_text: { |
|
|
|
|
|
|
|
borough: 'borough value' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var res = { |
|
|
|
|
|
|
|
data: [ |
|
|
|
|
|
|
|
{ name: 'postalcode 1', _matched_queries: ['fallback.postalcode'] }, |
|
|
|
|
|
|
|
{ name: 'postalcode 2', _matched_queries: ['fallback.postalcode'] }, |
|
|
|
|
|
|
|
{ name: 'neighbourhood 1', _matched_queries: ['fallback.neighbourhood'] }, |
|
|
|
|
|
|
|
{ name: 'borough 1', _matched_queries: ['fallback.borough'] }, |
|
|
|
|
|
|
|
{ name: 'borough 2', _matched_queries: ['fallback.borough'] }, |
|
|
|
|
|
|
|
{ name: 'locality 1', _matched_queries: ['fallback.locality'] }, |
|
|
|
|
|
|
|
{ name: 'localadmin 1', _matched_queries: ['fallback.localadmin'] }, |
|
|
|
|
|
|
|
{ name: 'county 1', _matched_queries: ['fallback.county'] }, |
|
|
|
|
|
|
|
{ name: 'macrocounty 1', _matched_queries: ['fallback.macrocounty'] }, |
|
|
|
|
|
|
|
{ name: 'region 1', _matched_queries: ['fallback.region'] }, |
|
|
|
|
|
|
|
{ name: 'macroregion 1', _matched_queries: ['fallback.macroregion'] }, |
|
|
|
|
|
|
|
{ name: 'dependency 1', _matched_queries: ['fallback.dependency'] }, |
|
|
|
|
|
|
|
{ name: 'country 1', _matched_queries: ['fallback.country'] }, |
|
|
|
|
|
|
|
{ name: 'unknown', _matched_queries: ['fallback.unknown'] } |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var expected_data = [ |
|
|
|
|
|
|
|
{ name: 'postalcode 1', _matched_queries: ['fallback.postalcode'] }, |
|
|
|
|
|
|
|
{ name: 'postalcode 2', _matched_queries: ['fallback.postalcode'] }, |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function testIt() { |
|
|
|
|
|
|
|
trimByGranularity(req, res, function() { |
|
|
|
|
|
|
|
t.deepEquals(res.data, expected_data, 'only postalcode records should be here'); |
|
|
|
|
|
|
|
t.end(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
testIt(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('all records with fallback.* matched_queries name should retain only neighbourhoods when they are most granular', function(t) { |
|
|
|
test('all records with fallback.* matched_queries name should retain only neighbourhoods when they are most granular', function(t) { |
|
|
|
var req = { clean: {} }; |
|
|
|
var req = { clean: {} }; |
|
|
|
|
|
|
|
|
|
|
|