Add a unit test for maximum number of articles in nearby search

This commit is contained in:
mossroy 2014-03-18 15:56:28 +01:00
parent c874814a24
commit 058533ae94
2 changed files with 1354 additions and 1340 deletions

View File

@ -328,6 +328,18 @@ define(function(require) {
localArchive.getTitlesInCoords(rectFranceGermany, 10, callbackTitlesNearbyFound);
});
asyncTest("check articles found nearby France and Germany, with a maximum", function() {
expect(2);
var callbackTitlesNearbyMaximumFound = function(titleList) {
ok(titleList !== null, "Some titles should be found");
equal(titleList.length, 2, "2 titles should be found");
start();
};
var rectFranceGermany = new geometry.rect(40,0,10,10);
localArchive.getTitlesInCoords(rectFranceGermany, 2, callbackTitlesNearbyMaximumFound);
});
asyncTest("check articles found nearby London", function() {
expect(3);
var callbackTitlesNearbyLondonFound = function(titleList) {

View File

@ -839,10 +839,12 @@ define(function(require) {
// so it's no use putting it in the result list : we only put
// the position in title list
console.log("target rectangle contains this point : adding to the list");
if (maxTitles >= 0 && titlePositionsFound.length < maxTitles) {
titlePositionsFound.push(title_pos);
console.log("maxTitles="+maxTitles+" titlePositionsFound.length="+titlePositionsFound.length);
}
}
}
if (callbackCounterForTitlesInCoordsSearch === 0) {
console.log("callbackCounterForTitlesInCoordsSearch reached 0 : return the titles found");
callbackGetTitlesInCoordsInt(localArchive, titlePositionsFound, maxTitles, callbackFunction);