import React from "react";
import { shallow } from "enzyme";
import ErrorModal from "../components/util/GameCreationForm/ErrorModal";

describe("ErrorModal", () => {
  it("renders", () => {
    const onClose = jest.fn();
    const rendered = shallow(<ErrorModal onClose={onClose} />);
    expect(rendered).toMatchSnapshot();
  });

  it("renders when open", () => {
    const onClose = jest.fn();
    const rendered = shallow(<ErrorModal open onClose={onClose} />);
    expect(rendered).toMatchSnapshot();
  });

  it("calls onClose when closed", () => {
    const onClose = jest.fn();
    const rendered = shallow(<ErrorModal open onClose={onClose} />);
    rendered.find("button").first().simulate("click");
    expect(onClose).toHaveBeenCalled();
  });
});
