mirror of
https://github.com/kiwix/kiwix-js.git
synced 2025-09-23 04:28:30 -04:00
Add a unit test for maximum number of articles in nearby search
This commit is contained in:
parent
c874814a24
commit
058533ae94
@ -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) {
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user