mirror of https://github.com/pelias/api.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.2 KiB
52 lines
1.2 KiB
var data = require('../fixture/dedupe_elasticsearch_results'); |
|
var dedupe = require('../../../middleware/dedupe')(); |
|
|
|
module.exports.tests = {}; |
|
|
|
module.exports.tests.dedupe = function(test, common) { |
|
test('filter out duplicates', function(t) { |
|
var req = { |
|
clean: { |
|
text: 'lampeter strasburg high school', |
|
size: 100 |
|
} |
|
}; |
|
var res = { |
|
data: data |
|
}; |
|
|
|
var expectedCount = 7; |
|
dedupe(req, res, function () { |
|
t.equal(res.data.length, expectedCount, 'results have fewer items than before'); |
|
t.end(); |
|
}); |
|
}); |
|
|
|
test('truncate results based on specified size', function(t) { |
|
var req = { |
|
clean: { |
|
text: 'lampeter strasburg high school', |
|
size: 3 |
|
} |
|
}; |
|
var res = { |
|
data: data |
|
}; |
|
|
|
dedupe(req, res, function () { |
|
t.equal(res.data.length, req.clean.size, 'results have fewer items than before'); |
|
t.end(); |
|
}); |
|
}); |
|
}; |
|
|
|
module.exports.all = function (tape, common) { |
|
|
|
function test(name, testFunction) { |
|
return tape('[middleware] dedupe: ' + name, testFunction); |
|
} |
|
|
|
for( var testCase in module.exports.tests ){ |
|
module.exports.tests[testCase](test, common); |
|
} |
|
};
|
|
|