import React from "react";
import { configure, shallow, render } from "enzyme";
import Adapter from "enzyme-adapter-react-16";
import EfeBadge from "../components/badge/Badge";
import { colors, badgeTypes } from "../constants/variables";

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

describe("Badge With Badge Color", () => {
  for (let index = 0; index < colors.length; index++) {
    test(`Badge color: ${colors[index]}`, () => {
      const component = shallow(<EfeBadge badgeColor={colors[index]} />);
      expect(component.find(`.efe-badge-${colors[index]}`)).toHaveLength(1);
    });
  }
});

describe("Badge With Types", () => {
  for (let index = 0; index < badgeTypes.length; index++) {
    test(`Badge type: ${badgeTypes[index]}`, () => {
      const component = shallow(<EfeBadge type={badgeTypes[index]} />);
      expect(component.find(`.efe-badge-${badgeTypes[index]}`)).toHaveLength(1);
    });
  }
});

describe("Both type and color of badge", () => {
  for (let i = 0; i < badgeTypes.length; i++) {
    for (let j = 0; j < colors.length; j++) {
      test(`Badge type: ${badgeTypes[i]}`, () => {
        const component = shallow(
          <EfeBadge badgeColor={colors[j]} type={badgeTypes[i]} />
        );
        expect(component.find(`.efe-badge-${badgeTypes[i]}`)).toHaveLength(1);
      });
    }
  }
});

describe("Badge Link", () => {
  test("Link control:", () => {
    const component = shallow(<EfeBadge link={"www.bilgeadam.com"} />);
    expect(component.find(`a`)).toHaveLength(1);
  });
});

describe("Badge Children Value Control", () => {
  test("Children control:", () => {
    const component = shallow(<EfeBadge>BilgeAdam</EfeBadge>);
    expect(component.text()).toEqual("BilgeAdam");
  });
});
