import React from "react";
import { configure, shallow, render } from "enzyme";
import Adapter from "enzyme-adapter-react-16";
import EfeAlert from "../components/alert/Alert";
import { colors } from "../constants/variables";
import { Alert } from "react-bootstrap";

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

describe("Alert Color Test", () => {
  for (let index = 0; index < colors.length; index++) {
    test(`Alert color: ${colors[index]}`, () => {
      const component = shallow(<EfeAlert variant={colors[index]} />);
      expect(component.find(Alert).prop("variant")).toEqual(colors[index]);
    });
  }
});

describe("Alert Dismissible Test", () => {
  test("Alert dismissible: false", () => {
    const component = shallow(<EfeAlert dismissible={false} />);
    expect(component.find(Alert).prop("dismissible")).toBe(false);
  });

  test("Alert dismissible: true", () => {
    const component = shallow(<EfeAlert dismissible={true} />);
    expect(component.find(Alert).prop("dismissible")).toBe(true);
  });
});

describe("Alert Classes Test", () => {
  test("Alert dismissible: false", () => {
    const component = shallow(<EfeAlert classes="mt-2" />);
    expect(component.find(Alert).prop("className")).toEqual("alert-card mt-2");
  });
});
