import React from "react";
import { configure, shallow, render } from "enzyme";
import Adapter from "enzyme-adapter-react-16";
import EfeButton from "../components/button/Button";
import { colors } from "../constants/variables";

configure({ adapter: new Adapter() });

const setUp = (props = {}) => {
  const component = shallow(<EfeButton />);
  return component;
};

describe("Button Click Test", () => {
  test(`Button one click:`, () => {
    const mockCallBack = jest.fn();
    const component = shallow(
      <EfeButton handleOnClick={mockCallBack}>Click</EfeButton>
    );
    component.find("button").simulate("click");
    expect(mockCallBack.mock.calls.length).toEqual(1);
  });
});

describe("Button Children Value Control", () => {
  test("Children control:", () => {
    const mockCallBack = jest.fn();
    const component = shallow(
      <EfeButton handleOnClick={mockCallBack}>Click</EfeButton>
    );
    expect(component.text()).toEqual("Click");
  });
});

describe("Default Button Test", () => {
  test("Default Button", () => {
    const mockCallBack = jest.fn();
    const component = shallow(<EfeButton handleOnClick={mockCallBack} />);
    expect(component.find(".efe-button")).toHaveLength(1);
  });
});

describe("Button Type Test", () => {
  test("Default Button", () => {
    const mockCallBack = jest.fn();
    const component = shallow(
      <EfeButton handleOnClick={mockCallBack} type="submit" />
    );
    expect(component.find("button").prop("type")).toBe("submit");
  });
});

describe("Button Disable Test", () => {
  test("Disable Button", () => {
    const mockCallBack = jest.fn();
    const component = shallow(
      <EfeButton handleOnClick={mockCallBack} disabled={true} />
    );
    expect(component.find("button").prop("disabled")).toBe(true);
  });
});
