import React from "react";
import { configure, shallow, render } from "enzyme";
import Adapter from "enzyme-adapter-react-16";
import EfeProgressbar from "../components/progressbar/Progressbar";
import { colors } from "../constants/variables";

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

describe("Progressbar Color Test", () => {
  for (let index = 0; index < colors.length; index++) {
    const component = shallow(<EfeProgressbar color={colors[index]} />);
    test(`Progressbar color:${colors[index]}`, () => {
      expect(component.find(`.efe-progress-bar-${colors[index]}`)).toHaveLength(
        1
      );
    });
  }
});

describe("Progressbar Animated Test", () => {
  const component = shallow(<EfeProgressbar animated />);
  test("Progressbar animated: animated test", () => {
    expect(component.find(".progress-bar-striped")).toHaveLength(1);
  });

  test("Progressbar animated: striped test", () => {
    expect(component.find(".progress-bar-animated")).toHaveLength(1);
  });
});

describe("Progressbar Striped Test", () => {
  const component = shallow(<EfeProgressbar striped />);
  test("Progressbar striped: striped", () => {
    expect(component.find(".progress-bar-striped")).toHaveLength(1);
  });
});

describe("Progressbar Child Component Test", () => {
  const component = shallow(<EfeProgressbar percent={"20"} percentIsActive />);
  test("Props:percent=20 percentIsActive", () => {
    expect(component.text()).toEqual("20%");
  });
});
