Skip to content

Commit

Permalink
Test new contextMenu handler for use-game hook
Browse files Browse the repository at this point in the history
  • Loading branch information
zourdyzou committed Aug 9, 2022
1 parent d10ff95 commit 2ebe4b8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/modules/GameWithHooks/hooks/use-game/use-game.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Field } from "@helpers/field";
import { CellState, Field } from "@helpers/field";
import { GameLevels, GameSettings } from "@modules/GameSettings";
import { useGame } from "@modules/GameWithHooks/hooks/use-game/index";
import { act, renderHook } from "@testing-library/react";
Expand Down Expand Up @@ -35,4 +35,14 @@ describe("useGame test cases", function () {
const { playerField: expertPlayerField } = result.current;
expect(expertPlayerField).toHaveLength(22);
});

it("should handler contextMenu handler", function () {
const { result } = renderHook(useGame);

const { onContextMenuHandler, playerField: newPlayerField } = result.current;

act(() => onContextMenuHandler([0, 0]));

expect(flatWithFilter(newPlayerField, CellState.mark)).toHaveLength(1);
});
});

0 comments on commit 2ebe4b8

Please sign in to comment.