ErrorModal.test.js 760 B

123456789101112131415161718192021222324
  1. import React from "react";
  2. import { shallow } from "enzyme";
  3. import ErrorModal from "../components/util/GameCreationForm/ErrorModal";
  4. describe("ErrorModal", () => {
  5. it("renders", () => {
  6. const onClose = jest.fn();
  7. const rendered = shallow(<ErrorModal onClose={onClose} />);
  8. expect(rendered).toMatchSnapshot();
  9. });
  10. it("renders when open", () => {
  11. const onClose = jest.fn();
  12. const rendered = shallow(<ErrorModal open onClose={onClose} />);
  13. expect(rendered).toMatchSnapshot();
  14. });
  15. it("calls onClose when closed", () => {
  16. const onClose = jest.fn();
  17. const rendered = shallow(<ErrorModal open onClose={onClose} />);
  18. rendered.find("button").first().simulate("click");
  19. expect(onClose).toHaveBeenCalled();
  20. });
  21. });