message: Refactor modal tests
diff: -import Enzyme, { mount, shallow } from "enzyme";
  +import Enzyme, { mount } from "enzyme";
  import Adapter from "enzyme-adapter-react-16";
  import faker from "faker";
  import React from "react";
  @@ -24,25 +24,19 @@ describe("modal specs", () => {
  expect(wrapper.exists(".modal-main")).toEqual(false);
  });
  - it("should render title sub component", () => {
  - const text = faker.random.word();
  + it("should render header sub component", () => {
  const wrapper = mount(
  <Modal show={true}>
  - <Modal.Title>
  - <h1>{text}</h1>
  - </Modal.Title>
  + <Modal.Header/>
  </Modal>,
  );
  - expect(wrapper.find(".modal-title")).toHaveLength(1);
  + expect(wrapper.find(".modal-header")).toHaveLength(1);
  });
  it("should render content sub component", () => {
  - const text = faker.random.word();
  const wrapper = mount(
  <Modal show={true}>
  - <Modal.Content>
  - <p>{text}</p>
  - </Modal.Content>
  + <Modal.Content/>
  </Modal>,
  );
  expect(wrapper.find(".modal-content")).toHaveLength(1);
  @@ -60,28 +54,33 @@ describe("modal specs", () => {
  expect(wrapper.find(".modal-actions")).toHaveLength(1);
  });
  - it("should have close icon button", () => {
  - const text = faker.random.word();
  + it("should have close icon button by default", () => {
  const wrapper = mount(
  <Modal show={true}>
  - <Modal.Title>
  - <h1>{text}</h1>
  - </Modal.Title>
  + <Modal.Header/>
  </Modal>,
  );
  expect(wrapper.find(".icon-close")).toHaveLength(1);
  });
  - it("should have back icon button", () => {
  - const wrapper = mount(<Modal show={true} icon="back"/>);
  -
  - expect(wrapper.find(".icon-back")).toHaveLength(1);
  + it("should not have icon button if noIcon prop is passed", () => {
  + const wrapper = mount(
  + <Modal show={true}>
  + <Modal.Header noIcon/>
  + </Modal>,
  + );
  + expect(wrapper.find(".icon-close")).toHaveLength(0);
  });
  - it("should render the icon on left if the iconPosition prop is given left", () => {
  - const wrapper = shallow(<Modal show={true} iconPosition="left"/>);
  -
  - expect(wrapper.find(".modal-icon-left")).toHaveLength(1);
  + it("should call onClose when icon is clicked", () => {
  + const onClose = sandbox.spy();
  + const wrapper = mount(
  + <Modal show={true}>
  + <Modal.Header onClose={onClose}/>
  + </Modal>,
  + );
  + wrapper.find("i").simulate("click");
  + expect(onClose.calledOnce).toEqual(true);
  });
  });
  