Skip to content

Commit 7cdb351

Browse files
committed
Fix websocket handler typing in MatchPage tests
1 parent 5d01118 commit 7cdb351

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

web/src/pages/match/MatchPage.test.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -556,12 +556,13 @@ describe("MatchPage queued human vs human", () => {
556556
expect(openPersistedGameSocketMock).toHaveBeenCalled();
557557
});
558558

559-
if (wsEventHandler === null) {
559+
if (typeof wsEventHandler !== "function") {
560560
throw new Error("Expected websocket handler to be initialized.");
561561
}
562+
const handleWsEvent = wsEventHandler as (event: PersistedGameWsEvent) => void;
562563

563564
const staleBoardAfter = createInitialBoard();
564-
wsEventHandler({
565+
handleWsEvent({
565566
type: "game.move.applied",
566567
game_id: "game-h2h",
567568
move: {
@@ -616,13 +617,14 @@ describe("MatchPage queued human vs human", () => {
616617
expect(openPersistedGameSocketMock).toHaveBeenCalled();
617618
});
618619

619-
if (wsEventHandler === null) {
620+
if (typeof wsEventHandler !== "function") {
620621
throw new Error("Expected websocket handler to be initialized.");
621622
}
623+
const handleWsEvent = wsEventHandler as (event: PersistedGameWsEvent) => void;
622624

623625
const boardAfter = createInitialBoard();
624626
boardAfter.half_moves = 1;
625-
wsEventHandler({
627+
handleWsEvent({
626628
type: "game.move.applied",
627629
game_id: "game-h2h",
628630
move: {

0 commit comments

Comments
 (0)