mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Merge pull request #14245 from Snuffleupagus/PDFPageViewBuffer-class
Convert `PDFPageViewBuffer` to a standard class, and use a `Set` internally
This commit is contained in:
commit
891f21fba6
4 changed files with 65 additions and 100 deletions
|
@ -136,12 +136,12 @@ describe("BaseViewer", function () {
|
|||
|
||||
// Ensure that decreasing the size will evict the correct views,
|
||||
// while re-ordering the remaining ones correctly.
|
||||
buffer.resize(3, new Set([1, 2, 3]));
|
||||
buffer.resize(3, new Set([1, 2, 5]));
|
||||
|
||||
expect(buffer._buffer).toEqual([
|
||||
viewsMap.get(1),
|
||||
viewsMap.get(2),
|
||||
viewsMap.get(3),
|
||||
viewsMap.get(5),
|
||||
]);
|
||||
});
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ import {
|
|||
getVisibleElements,
|
||||
isPortraitOrientation,
|
||||
isValidRotation,
|
||||
moveToEndOfArray,
|
||||
parseQueryString,
|
||||
waitOnEventOrTimeout,
|
||||
WaitOnType,
|
||||
|
@ -864,44 +863,4 @@ describe("ui_utils", function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("moveToEndOfArray", function () {
|
||||
it("works on empty arrays", function () {
|
||||
const data = [];
|
||||
moveToEndOfArray(data, function () {});
|
||||
expect(data).toEqual([]);
|
||||
});
|
||||
|
||||
it("works when moving everything", function () {
|
||||
const data = [1, 2, 3, 4, 5];
|
||||
moveToEndOfArray(data, function () {
|
||||
return true;
|
||||
});
|
||||
expect(data).toEqual([1, 2, 3, 4, 5]);
|
||||
});
|
||||
|
||||
it("works when moving some things", function () {
|
||||
const data = [1, 2, 3, 4, 5];
|
||||
moveToEndOfArray(data, function (x) {
|
||||
return x % 2 === 0;
|
||||
});
|
||||
expect(data).toEqual([1, 3, 5, 2, 4]);
|
||||
});
|
||||
|
||||
it("works when moving one thing", function () {
|
||||
const data = [1, 2, 3, 4, 5];
|
||||
moveToEndOfArray(data, function (x) {
|
||||
return x === 1;
|
||||
});
|
||||
expect(data).toEqual([2, 3, 4, 5, 1]);
|
||||
});
|
||||
|
||||
it("works when moving nothing", function () {
|
||||
const data = [1, 2, 3, 4, 5];
|
||||
moveToEndOfArray(data, function (x) {
|
||||
return x === 0;
|
||||
});
|
||||
expect(data).toEqual([1, 2, 3, 4, 5]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue