|
@@ -0,0 +1,50 @@
|
|
|
+import React from "react";
|
|
|
+import { shallow } from "enzyme";
|
|
|
+import { FROZEN, NORMAL, RACE } from "../domain/ruleSets";
|
|
|
+import GamePanel from "../components/screens/GamePanel";
|
|
|
+
|
|
|
+jest.mock("../domain/gameStore");
|
|
|
+jest.mock("../hooks/usePreventNavigation");
|
|
|
+jest.mock("../hooks/useGameInfo");
|
|
|
+
|
|
|
+import usePreventNavigation from "../hooks/usePreventNavigation";
|
|
|
+import { useGameConfig } from "../hooks/useGameInfo";
|
|
|
+import { useCurrentRound } from "../domain/gameStore";
|
|
|
+
|
|
|
+describe("GamePanel", () => {
|
|
|
+ it("renders for NORMAL game", () => {
|
|
|
+ useCurrentRound.mockReturnValue("");
|
|
|
+ useGameConfig.mockReturnValue({ ruleSet: NORMAL });
|
|
|
+ const rendered = shallow(<GamePanel/>);
|
|
|
+ expect(rendered).toMatchSnapshot();
|
|
|
+ expect(usePreventNavigation).toHaveBeenCalled();
|
|
|
+ expect(useGameConfig).toHaveBeenCalled();
|
|
|
+ });
|
|
|
+
|
|
|
+ it("renders for end of game", () => {
|
|
|
+ useCurrentRound.mockReturnValue(null);
|
|
|
+ useGameConfig.mockReturnValue({ ruleSet: NORMAL });
|
|
|
+ const rendered = shallow(<GamePanel/>);
|
|
|
+ expect(rendered).toMatchSnapshot();
|
|
|
+ expect(usePreventNavigation).toHaveBeenCalled();
|
|
|
+ expect(useGameConfig).toHaveBeenCalled();
|
|
|
+ });
|
|
|
+
|
|
|
+ it("renders for FROZEN game", () => {
|
|
|
+ useCurrentRound.mockReturnValue("");
|
|
|
+ useGameConfig.mockReturnValue({ ruleSet: FROZEN });
|
|
|
+ const rendered = shallow(<GamePanel/>);
|
|
|
+ expect(rendered).toMatchSnapshot();
|
|
|
+ expect(usePreventNavigation).toHaveBeenCalled();
|
|
|
+ expect(useGameConfig).toHaveBeenCalled();
|
|
|
+ });
|
|
|
+
|
|
|
+ it("renders for RACE game", () => {
|
|
|
+ useCurrentRound.mockReturnValue("");
|
|
|
+ useGameConfig.mockReturnValue({ ruleSet: RACE });
|
|
|
+ const rendered = shallow(<GamePanel/>);
|
|
|
+ expect(rendered).toMatchSnapshot();
|
|
|
+ expect(usePreventNavigation).toHaveBeenCalled();
|
|
|
+ expect(useGameConfig).toHaveBeenCalled();
|
|
|
+ });
|
|
|
+});
|