|
|
@ -337,26 +337,26 @@ module.exports.tests.trimByGranularity = function(test, common) { |
|
|
|
testIt(); |
|
|
|
testIt(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('all records with fallback.* matched_queries name should retain only dependencies when they are most granular', function(t) { |
|
|
|
test('all records with fallback.* matched_queries name should retain countries over dependencies', function(t) { |
|
|
|
var req = { clean: {} }; |
|
|
|
var req = { clean: {} }; |
|
|
|
|
|
|
|
|
|
|
|
var res = { |
|
|
|
var res = { |
|
|
|
data: [ |
|
|
|
data: [ |
|
|
|
{ name: 'dependency 1', _matched_queries: ['fallback.dependency'] }, |
|
|
|
{ name: 'dependency 1', _matched_queries: ['fallback.dependency'] }, |
|
|
|
{ name: 'dependency 2', _matched_queries: ['fallback.dependency'] }, |
|
|
|
|
|
|
|
{ name: 'country 1', _matched_queries: ['fallback.country'] }, |
|
|
|
{ name: 'country 1', _matched_queries: ['fallback.country'] }, |
|
|
|
|
|
|
|
{ name: 'country 2', _matched_queries: ['fallback.country'] }, |
|
|
|
{ name: 'unknown', _matched_queries: ['fallback.unknown'] } |
|
|
|
{ name: 'unknown', _matched_queries: ['fallback.unknown'] } |
|
|
|
] |
|
|
|
] |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var expected_data = [ |
|
|
|
var expected_data = [ |
|
|
|
{ name: 'dependency 1', _matched_queries: ['fallback.dependency'] }, |
|
|
|
{ name: 'country 1', _matched_queries: ['fallback.country'] }, |
|
|
|
{ name: 'dependency 2', _matched_queries: ['fallback.dependency'] }, |
|
|
|
{ name: 'country 2', _matched_queries: ['fallback.country'] }, |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
function testIt() { |
|
|
|
function testIt() { |
|
|
|
trimByGranularity(req, res, function() { |
|
|
|
trimByGranularity(req, res, function() { |
|
|
|
t.deepEquals(res.data, expected_data, 'only dependency records should be here'); |
|
|
|
t.deepEquals(res.data, expected_data, 'only country records should be here'); |
|
|
|
t.end(); |
|
|
|
t.end(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
@ -364,25 +364,25 @@ module.exports.tests.trimByGranularity = function(test, common) { |
|
|
|
testIt(); |
|
|
|
testIt(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('all records with fallback.* matched_queries name should retain only countries when they are most granular', function(t) { |
|
|
|
test('all records with fallback.* matched_queries name should retain only dependencies when they are most granular', function(t) { |
|
|
|
var req = { clean: {} }; |
|
|
|
var req = { clean: {} }; |
|
|
|
|
|
|
|
|
|
|
|
var res = { |
|
|
|
var res = { |
|
|
|
data: [ |
|
|
|
data: [ |
|
|
|
{ name: 'country 1', _matched_queries: ['fallback.country'] }, |
|
|
|
{ name: 'dependency 1', _matched_queries: ['fallback.dependency'] }, |
|
|
|
{ name: 'country 2', _matched_queries: ['fallback.country'] }, |
|
|
|
{ name: 'dependency 2', _matched_queries: ['fallback.dependency'] }, |
|
|
|
{ name: 'unknown', _matched_queries: ['fallback.unknown'] } |
|
|
|
{ name: 'unknown', _matched_queries: ['fallback.unknown'] } |
|
|
|
] |
|
|
|
] |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var expected_data = [ |
|
|
|
var expected_data = [ |
|
|
|
{ name: 'country 1', _matched_queries: ['fallback.country'] }, |
|
|
|
{ name: 'dependency 1', _matched_queries: ['fallback.dependency'] }, |
|
|
|
{ name: 'country 2', _matched_queries: ['fallback.country'] }, |
|
|
|
{ name: 'dependency 2', _matched_queries: ['fallback.dependency'] }, |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
function testIt() { |
|
|
|
function testIt() { |
|
|
|
trimByGranularity(req, res, function() { |
|
|
|
trimByGranularity(req, res, function() { |
|
|
|
t.deepEquals(res.data, expected_data, 'only country records should be here'); |
|
|
|
t.deepEquals(res.data, expected_data, 'only dependency records should be here'); |
|
|
|
t.end(); |
|
|
|
t.end(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|