Skip to content

Commit

Permalink
Unit test to help verify updateFindControlState
Browse files Browse the repository at this point in the history
Do a simple find and check the params pass to `updatefindcontrolstate` is in
expected shape.
  • Loading branch information
bootleq committed Jun 20, 2024
1 parent 003acde commit fbdc420
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/unit/pdf_find_controller_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1022,4 +1022,35 @@ describe("pdf_find_controller", function () {
pageMatchesLength: [[1, 1, 1, 1, 1, 1, 1, 1, 1]],
});
});

it("dispatches updateFindControlState with picked state properties", async function () {
const testOnFind = ({ eventBus }) =>
new Promise(function (resolve) {
const eventState = {
source: this,
type: "",
query: "Foo",
caseSensitive: true,
entireWord: true,
findPrevious: false,
matchDiacritics: false,
};
eventBus.dispatch("find", eventState);

eventBus.on(
"updatefindcontrolstate",
function onUpdatefindcontrolstate(evt) {
expect(evt.state).toBe(FindState.NOT_FOUND);
expect(evt.previous).toBe(false);
expect(evt.entireWord).toBe(true);
expect(evt.matchesCount).toEqual({ current: 0, total: 0 });
expect(evt.rawQuery).toBe("Foo");
resolve();
}
);
});

const { eventBus } = await initPdfFindController();
await testOnFind({ eventBus });
});
});

0 comments on commit fbdc420

Please sign in to comment.