|
|
|
@ -19,8 +19,8 @@ module.exports.tests.trimByGranularity = function(test, common) {
|
|
|
|
|
data: [ |
|
|
|
|
{ name: 'venue 1', _matched_queries: ['fallback.venue'] }, |
|
|
|
|
{ name: 'venue 2', _matched_queries: ['fallback.venue'] }, |
|
|
|
|
{ name: 'street 1', _matched_queries: ['fallback.street'] }, |
|
|
|
|
{ name: 'address 1', _matched_queries: ['fallback.address'] }, |
|
|
|
|
{ name: 'street 1', _matched_queries: ['fallback.street'] }, |
|
|
|
|
{ name: 'neighbourhood 1', _matched_queries: ['fallback.neighbourhood'] }, |
|
|
|
|
{ name: 'borough 1', _matched_queries: ['fallback.borough'] }, |
|
|
|
|
{ name: 'locality 1', _matched_queries: ['fallback.locality'] }, |
|
|
|
@ -55,9 +55,9 @@ module.exports.tests.trimByGranularity = function(test, common) {
|
|
|
|
|
|
|
|
|
|
var res = { |
|
|
|
|
data: [ |
|
|
|
|
{ name: 'street 1', _matched_queries: ['fallback.street'] }, |
|
|
|
|
{ name: 'street 2', _matched_queries: ['fallback.street'] }, |
|
|
|
|
{ name: 'address 1', _matched_queries: ['fallback.address'] }, |
|
|
|
|
{ name: 'address 2', _matched_queries: ['fallback.address'] }, |
|
|
|
|
{ name: 'street 1', _matched_queries: ['fallback.street'] }, |
|
|
|
|
{ name: 'neighbourhood 1', _matched_queries: ['fallback.neighbourhood'] }, |
|
|
|
|
{ name: 'borough 1', _matched_queries: ['fallback.borough'] }, |
|
|
|
|
{ name: 'locality 1', _matched_queries: ['fallback.locality'] }, |
|
|
|
@ -73,13 +73,13 @@ module.exports.tests.trimByGranularity = function(test, common) {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var expected_data = [ |
|
|
|
|
{ name: 'street 1', _matched_queries: ['fallback.street'] }, |
|
|
|
|
{ name: 'street 2', _matched_queries: ['fallback.street'] } |
|
|
|
|
{ name: 'address 1', _matched_queries: ['fallback.address'] }, |
|
|
|
|
{ name: 'address 2', _matched_queries: ['fallback.address'] } |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
function testIt() { |
|
|
|
|
trimByGranularity(req, res, function() { |
|
|
|
|
t.deepEquals(res.data, expected_data, 'only street records should be here'); |
|
|
|
|
t.deepEquals(res.data, expected_data, 'only address records should be here'); |
|
|
|
|
t.end(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
@ -87,13 +87,13 @@ module.exports.tests.trimByGranularity = function(test, common) {
|
|
|
|
|
testIt(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('all records with fallback.* matched_queries name should retain only address when they are most granular', function(t) { |
|
|
|
|
test('all records with fallback.* matched_queries name should retain only street when they are most granular', function(t) { |
|
|
|
|
var req = { clean: {} }; |
|
|
|
|
|
|
|
|
|
var res = { |
|
|
|
|
data: [ |
|
|
|
|
{ name: 'address 1', _matched_queries: ['fallback.address'] }, |
|
|
|
|
{ name: 'address 2', _matched_queries: ['fallback.address'] }, |
|
|
|
|
{ name: 'street 1', _matched_queries: ['fallback.street'] }, |
|
|
|
|
{ name: 'street 2', _matched_queries: ['fallback.street'] }, |
|
|
|
|
{ name: 'neighbourhood 1', _matched_queries: ['fallback.neighbourhood'] }, |
|
|
|
|
{ name: 'borough 1', _matched_queries: ['fallback.borough'] }, |
|
|
|
|
{ name: 'locality 1', _matched_queries: ['fallback.locality'] }, |
|
|
|
@ -109,13 +109,13 @@ module.exports.tests.trimByGranularity = function(test, common) {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var expected_data = [ |
|
|
|
|
{ name: 'address 1', _matched_queries: ['fallback.address'] }, |
|
|
|
|
{ name: 'address 2', _matched_queries: ['fallback.address'] }, |
|
|
|
|
{ name: 'street 1', _matched_queries: ['fallback.street'] }, |
|
|
|
|
{ name: 'street 2', _matched_queries: ['fallback.street'] }, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
function testIt() { |
|
|
|
|
trimByGranularity(req, res, function() { |
|
|
|
|
t.deepEquals(res.data, expected_data, 'only address records should be here'); |
|
|
|
|
t.deepEquals(res.data, expected_data, 'only street records should be here'); |
|
|
|
|
t.end(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|