12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import React from "react";
- import { shallow } from "enzyme";
- import PositionedStreetView from "../components/screens/GamePanel/PositionedStreetView";
- jest.mock("../domain/gameStore");
- jest.mock("../components/screens/GamePanel/hooks");
- import {
- usePanoStartPosition,
- usePanoStartPov,
- useTargetPoint,
- } from "../domain/gameStore";
- import { usePano } from "../components/screens/GamePanel/hooks";
- describe("PositionedStreetView", () => {
- it("renders", () => {
- usePanoStartPosition.mockReturnValue();
- usePanoStartPov.mockReturnValue();
- useTargetPoint.mockReturnValue();
- const rendered = shallow(<PositionedStreetView />);
- expect(rendered).toMatchSnapshot();
- expect(usePano).toHaveBeenCalled();
- });
- it("resets", () => {
- usePanoStartPosition.mockReturnValue();
- usePanoStartPov.mockReturnValue();
- useTargetPoint.mockReturnValue("point");
- const setPosition = jest.fn();
- usePano.mockReturnValue({ current: { setPosition } });
- const handle = shallow(<PositionedStreetView />);
- expect(handle).toMatchSnapshot();
- handle.find("div.resetButton").first().simulate("click");
- expect(setPosition).toHaveBeenCalledWith("point");
- });
- it("resets on enter on button", () => {
- usePanoStartPosition.mockReturnValue();
- usePanoStartPov.mockReturnValue();
- useTargetPoint.mockReturnValue("point");
- const setPosition = jest.fn();
- usePano.mockReturnValue({ current: { setPosition } });
- const handle = shallow(<PositionedStreetView />);
- expect(handle).toMatchSnapshot();
- handle
- .find("div.resetButton")
- .first()
- .simulate("keydown", { key: "Enter" });
- expect(setPosition).toHaveBeenCalledWith("point");
- });
- it("does not reset on other keys on button", () => {
- usePanoStartPosition.mockReturnValue();
- usePanoStartPov.mockReturnValue();
- useTargetPoint.mockReturnValue("point");
- const setPosition = jest.fn();
- usePano.mockReturnValue({ current: { setPosition } });
- const handle = shallow(<PositionedStreetView />);
- expect(handle).toMatchSnapshot();
- handle
- .find("div.resetButton")
- .first()
- .simulate("keydown", { key: "Escape" });
- expect(setPosition).not.toHaveBeenCalled();
- });
- });
|