|
|
|
@ -12,28 +12,26 @@ module.exports.tests.trimByGranularity = function(test, common) {
|
|
|
|
|
t.end(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('when venue records are most granular, only they should be retained', function(t) { |
|
|
|
|
test('all records with fallback.* matched_queries name should retain only venues when they are most granular', function(t) { |
|
|
|
|
var req = { clean: {} }; |
|
|
|
|
|
|
|
|
|
var res = { |
|
|
|
|
data: [ |
|
|
|
|
{ name: 'venue 1', layer: 'venue' }, |
|
|
|
|
{ name: 'venue 2', layer: 'venue' }, |
|
|
|
|
{ name: 'address 1', layer: 'address' }, |
|
|
|
|
{ name: 'neighbourhood 1', layer: 'neighbourhood' }, |
|
|
|
|
{ name: 'locality 1', layer: 'locality' }, |
|
|
|
|
{ name: 'localadmin 1', layer: 'localadmin' }, |
|
|
|
|
{ name: 'county 1', layer: 'county' }, |
|
|
|
|
{ name: 'macrocounty 1', layer: 'macrocounty' }, |
|
|
|
|
{ name: 'region 1', layer: 'region' }, |
|
|
|
|
{ name: 'macroregion 1', layer: 'macroregion' }, |
|
|
|
|
{ name: 'country 1', layer: 'country' } |
|
|
|
|
{ name: 'venue 1', _matched_queries: ['fallback.venue'] }, |
|
|
|
|
{ name: 'venue 2', _matched_queries: ['fallback.venue'] }, |
|
|
|
|
{ name: 'address 1', _matched_queries: ['fallback.address'] }, |
|
|
|
|
{ name: 'neighbourhood 1', _matched_queries: ['fallback.neighbourhood'] }, |
|
|
|
|
{ name: 'locality 1', _matched_queries: ['fallback.locality'] }, |
|
|
|
|
{ name: 'county 1', _matched_queries: ['fallback.county'] }, |
|
|
|
|
{ name: 'region 1', _matched_queries: ['fallback.region'] }, |
|
|
|
|
{ name: 'country 1', _matched_queries: ['fallback.country'] }, |
|
|
|
|
{ name: 'unknown', _matched_queries: ['fallback.unknown'] } |
|
|
|
|
] |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var expected_data = [ |
|
|
|
|
{ name: 'venue 1', layer: 'venue' }, |
|
|
|
|
{ name: 'venue 2', layer: 'venue' }, |
|
|
|
|
{ name: 'venue 1', _matched_queries: ['fallback.venue'] }, |
|
|
|
|
{ name: 'venue 2', _matched_queries: ['fallback.venue'] }, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
function testIt() { |
|
|
|
@ -44,30 +42,27 @@ module.exports.tests.trimByGranularity = function(test, common) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
testIt(); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('when address records are most granular, only they should be retained', function(t) { |
|
|
|
|
test('all records with fallback.* matched_queries name should retain only addresses when they are most granular', function(t) { |
|
|
|
|
var req = { clean: {} }; |
|
|
|
|
|
|
|
|
|
var res = { |
|
|
|
|
data: [ |
|
|
|
|
{ name: 'address 1', layer: 'address' }, |
|
|
|
|
{ name: 'address 2', layer: 'address' }, |
|
|
|
|
{ name: 'neighbourhood 1', layer: 'neighbourhood' }, |
|
|
|
|
{ name: 'locality 1', layer: 'locality' }, |
|
|
|
|
{ name: 'localadmin 1', layer: 'localadmin' }, |
|
|
|
|
{ name: 'county 1', layer: 'county' }, |
|
|
|
|
{ name: 'macrocounty 1', layer: 'macrocounty' }, |
|
|
|
|
{ name: 'region 1', layer: 'region' }, |
|
|
|
|
{ name: 'macroregion 1', layer: 'macroregion' }, |
|
|
|
|
{ name: 'country 1', layer: 'country' }, |
|
|
|
|
{ name: 'address 1', _matched_queries: ['fallback.address'] }, |
|
|
|
|
{ name: 'address 2', _matched_queries: ['fallback.address'] }, |
|
|
|
|
{ name: 'neighbourhood 1', _matched_queries: ['fallback.neighbourhood'] }, |
|
|
|
|
{ name: 'locality 1', _matched_queries: ['fallback.locality'] }, |
|
|
|
|
{ name: 'county 1', _matched_queries: ['fallback.county'] }, |
|
|
|
|
{ name: 'region 1', _matched_queries: ['fallback.region'] }, |
|
|
|
|
{ name: 'country 1', _matched_queries: ['fallback.country'] }, |
|
|
|
|
{ name: 'unknown', _matched_queries: ['fallback.unknown'] } |
|
|
|
|
] |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var expected_data = [ |
|
|
|
|
{ name: 'address 1', layer: 'address' }, |
|
|
|
|
{ name: 'address 2', layer: 'address' } |
|
|
|
|
{ name: 'address 1', _matched_queries: ['fallback.address'] }, |
|
|
|
|
{ name: 'address 2', _matched_queries: ['fallback.address'] }, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
function testIt() { |
|
|
|
@ -78,31 +73,26 @@ module.exports.tests.trimByGranularity = function(test, common) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
testIt(); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('when neighbourhood records are most granular, only they should be retained', 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 res = { |
|
|
|
|
data: [ |
|
|
|
|
{ name: 'neighbourhood 1', layer: 'neighbourhood' }, |
|
|
|
|
{ name: 'neighbourhood 2', layer: 'neighbourhood' }, |
|
|
|
|
{ name: 'locality 1', layer: 'locality' }, |
|
|
|
|
{ name: 'locality 2', layer: 'locality' }, |
|
|
|
|
{ name: 'localadmin 1', layer: 'localadmin' }, |
|
|
|
|
{ name: 'localadmin 2', layer: 'localadmin' }, |
|
|
|
|
{ name: 'county 1', layer: 'county' }, |
|
|
|
|
{ name: 'macrocounty 1', layer: 'macrocounty' }, |
|
|
|
|
{ name: 'region 1', layer: 'region' }, |
|
|
|
|
{ name: 'macroregion 1', layer: 'macroregion' }, |
|
|
|
|
{ name: 'country 1', layer: 'country' } |
|
|
|
|
{ name: 'neighbourhood 1', _matched_queries: ['fallback.neighbourhood'] }, |
|
|
|
|
{ name: 'neighbourhood 2', _matched_queries: ['fallback.neighbourhood'] }, |
|
|
|
|
{ name: 'locality 1', _matched_queries: ['fallback.locality'] }, |
|
|
|
|
{ name: 'county 1', _matched_queries: ['fallback.county'] }, |
|
|
|
|
{ name: 'region 1', _matched_queries: ['fallback.region'] }, |
|
|
|
|
{ name: 'country 1', _matched_queries: ['fallback.country'] }, |
|
|
|
|
{ name: 'unknown', _matched_queries: ['fallback.unknown'] } |
|
|
|
|
] |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var expected_data = [ |
|
|
|
|
{ name: 'neighbourhood 1', layer: 'neighbourhood' }, |
|
|
|
|
{ name: 'neighbourhood 2', layer: 'neighbourhood' } |
|
|
|
|
{ name: 'neighbourhood 1', _matched_queries: ['fallback.neighbourhood'] }, |
|
|
|
|
{ name: 'neighbourhood 2', _matched_queries: ['fallback.neighbourhood'] }, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
function testIt() { |
|
|
|
@ -113,121 +103,106 @@ module.exports.tests.trimByGranularity = function(test, common) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
testIt(); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('when locality/localadmin records are most granular, only they should be retained', function(t) { |
|
|
|
|
test('all records with fallback.* matched_queries name should retain only localities when they are most granular', function(t) { |
|
|
|
|
var req = { clean: {} }; |
|
|
|
|
|
|
|
|
|
var res = { |
|
|
|
|
data: [ |
|
|
|
|
{ name: 'locality 1', layer: 'locality' }, |
|
|
|
|
{ name: 'locality 2', layer: 'locality' }, |
|
|
|
|
{ name: 'localadmin 1', layer: 'localadmin' }, |
|
|
|
|
{ name: 'localadmin 2', layer: 'localadmin' }, |
|
|
|
|
{ name: 'county 1', layer: 'county' }, |
|
|
|
|
{ name: 'macrocounty 1', layer: 'macrocounty' }, |
|
|
|
|
{ name: 'region 1', layer: 'region' }, |
|
|
|
|
{ name: 'macroregion 1', layer: 'macroregion' }, |
|
|
|
|
{ name: 'country 1', layer: 'country' }, |
|
|
|
|
{ name: 'locality 1', _matched_queries: ['fallback.locality'] }, |
|
|
|
|
{ name: 'locality 2', _matched_queries: ['fallback.locality'] }, |
|
|
|
|
{ name: 'county 1', _matched_queries: ['fallback.county'] }, |
|
|
|
|
{ name: 'region 1', _matched_queries: ['fallback.region'] }, |
|
|
|
|
{ name: 'country 1', _matched_queries: ['fallback.country'] }, |
|
|
|
|
{ name: 'unknown', _matched_queries: ['fallback.unknown'] } |
|
|
|
|
] |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var expected_data = [ |
|
|
|
|
{ name: 'locality 1', layer: 'locality' }, |
|
|
|
|
{ name: 'locality 2', layer: 'locality' }, |
|
|
|
|
{ name: 'localadmin 1', layer: 'localadmin' }, |
|
|
|
|
{ name: 'localadmin 2', layer: 'localadmin' } |
|
|
|
|
{ name: 'locality 1', _matched_queries: ['fallback.locality'] }, |
|
|
|
|
{ name: 'locality 2', _matched_queries: ['fallback.locality'] }, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
function testIt() { |
|
|
|
|
trimByGranularity(req, res, function() { |
|
|
|
|
t.deepEquals(res.data, expected_data, 'only locality/localadmin records should be here'); |
|
|
|
|
t.deepEquals(res.data, expected_data, 'only locality records should be here'); |
|
|
|
|
t.end(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
testIt(); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('when county/macrocounty records are most granular, only they should be retained', function(t) { |
|
|
|
|
test('all records with fallback.* matched_queries name should retain only venues when they are most granular', function(t) { |
|
|
|
|
var req = { clean: {} }; |
|
|
|
|
|
|
|
|
|
var res = { |
|
|
|
|
data: [ |
|
|
|
|
{ name: 'county 1', layer: 'county' }, |
|
|
|
|
{ name: 'county 2', layer: 'county' }, |
|
|
|
|
{ name: 'macrocounty 1', layer: 'macrocounty' }, |
|
|
|
|
{ name: 'macrocounty 2', layer: 'macrocounty' }, |
|
|
|
|
{ name: 'region 1', layer: 'region' }, |
|
|
|
|
{ name: 'macroregion 1', layer: 'macroregion' }, |
|
|
|
|
{ name: 'country 1', layer: 'country' }, |
|
|
|
|
{ name: 'county 1', _matched_queries: ['fallback.county'] }, |
|
|
|
|
{ name: 'county 2', _matched_queries: ['fallback.county'] }, |
|
|
|
|
{ name: 'region 1', _matched_queries: ['fallback.region'] }, |
|
|
|
|
{ name: 'country 1', _matched_queries: ['fallback.country'] }, |
|
|
|
|
{ name: 'unknown', _matched_queries: ['fallback.unknown'] } |
|
|
|
|
] |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var expected_data = [ |
|
|
|
|
{ name: 'county 1', layer: 'county' }, |
|
|
|
|
{ name: 'county 2', layer: 'county' }, |
|
|
|
|
{ name: 'macrocounty 1', layer: 'macrocounty' }, |
|
|
|
|
{ name: 'macrocounty 2', layer: 'macrocounty' }, |
|
|
|
|
{ name: 'county 1', _matched_queries: ['fallback.county'] }, |
|
|
|
|
{ name: 'county 2', _matched_queries: ['fallback.county'] }, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
function testIt() { |
|
|
|
|
trimByGranularity(req, res, function() { |
|
|
|
|
t.deepEquals(res.data, expected_data, 'only county/macrocounty records should be here'); |
|
|
|
|
t.deepEquals(res.data, expected_data, 'only county records should be here'); |
|
|
|
|
t.end(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
testIt(); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('when region/macroregion records are most granular, only they should be retained', function(t) { |
|
|
|
|
test('all records with fallback.* matched_queries name should retain only venues when they are most granular', function(t) { |
|
|
|
|
var req = { clean: {} }; |
|
|
|
|
|
|
|
|
|
var res = { |
|
|
|
|
data: [ |
|
|
|
|
{ name: 'region 1', layer: 'region' }, |
|
|
|
|
{ name: 'region 2', layer: 'region' }, |
|
|
|
|
{ name: 'macroregion 1', layer: 'macroregion' }, |
|
|
|
|
{ name: 'macroregion 2', layer: 'macroregion' }, |
|
|
|
|
{ name: 'country 1', layer: 'country' }, |
|
|
|
|
{ name: 'region 1', _matched_queries: ['fallback.region'] }, |
|
|
|
|
{ name: 'region 2', _matched_queries: ['fallback.region'] }, |
|
|
|
|
{ name: 'country 1', _matched_queries: ['fallback.country'] }, |
|
|
|
|
{ name: 'unknown', _matched_queries: ['fallback.unknown'] } |
|
|
|
|
] |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var expected_data = [ |
|
|
|
|
{ name: 'region 1', layer: 'region' }, |
|
|
|
|
{ name: 'region 2', layer: 'region' }, |
|
|
|
|
{ name: 'macroregion 1', layer: 'macroregion' }, |
|
|
|
|
{ name: 'macroregion 2', layer: 'macroregion' } |
|
|
|
|
{ name: 'region 1', _matched_queries: ['fallback.region'] }, |
|
|
|
|
{ name: 'region 2', _matched_queries: ['fallback.region'] }, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
function testIt() { |
|
|
|
|
trimByGranularity(req, res, function() { |
|
|
|
|
t.deepEquals(res.data, expected_data, 'only region/macroregion records should be here'); |
|
|
|
|
t.deepEquals(res.data, expected_data, 'only region records should be here'); |
|
|
|
|
t.end(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
testIt(); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('when country records are most granular, only they should be retained', function(t) { |
|
|
|
|
test('all records with fallback.* matched_queries name should retain only countries when they are most granular', function(t) { |
|
|
|
|
var req = { clean: {} }; |
|
|
|
|
|
|
|
|
|
var res = { |
|
|
|
|
data: [ |
|
|
|
|
{ name: 'country 1', layer: 'country' }, |
|
|
|
|
{ name: 'country 2', layer: 'country' } |
|
|
|
|
{ name: 'country 1', _matched_queries: ['fallback.country'] }, |
|
|
|
|
{ name: 'country 2', _matched_queries: ['fallback.country'] }, |
|
|
|
|
{ name: 'unknown', _matched_queries: ['fallback.unknown'] } |
|
|
|
|
] |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var expected_data = [ |
|
|
|
|
{ name: 'country 1', layer: 'country' }, |
|
|
|
|
{ name: 'country 2', layer: 'country' } |
|
|
|
|
{ name: 'country 1', _matched_queries: ['fallback.country'] }, |
|
|
|
|
{ name: 'country 2', _matched_queries: ['fallback.country'] }, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
function testIt() { |
|
|
|
@ -237,6 +212,33 @@ module.exports.tests.trimByGranularity = function(test, common) {
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
testIt(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('presence of any non-fallback.* named queries should not trim', function(t) { |
|
|
|
|
var req = { clean: {} }; |
|
|
|
|
|
|
|
|
|
var res = { |
|
|
|
|
data: [ |
|
|
|
|
{ name: 'region', _matched_queries: ['fallback.region'] }, |
|
|
|
|
{ name: 'country', _matched_queries: ['fallback.country'] }, |
|
|
|
|
{ name: 'result with non-named query' } |
|
|
|
|
] |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var expected_data = [ |
|
|
|
|
{ name: 'region', _matched_queries: ['fallback.region'] }, |
|
|
|
|
{ name: 'country', _matched_queries: ['fallback.country'] }, |
|
|
|
|
{ name: 'result with non-named query' } |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
function testIt() { |
|
|
|
|
trimByGranularity(req, res, function() { |
|
|
|
|
t.deepEquals(res.data, expected_data, 'all should results should have been retained'); |
|
|
|
|
t.end(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
testIt(); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|