import React from "react";
import { configure, shallow, render } from "enzyme";
import Adapter from "enzyme-adapter-react-16";
import EfeSpinner from "../components/spinner/Spinner";
import {
  colors,
  spinnerModes,
  spinnerAnimations
} from "../constants/variables";

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

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

describe("Spinner Animation Test", () => {
  for (let index = 0; index < spinnerAnimations.length; index++) {
    test(`Animation: ${spinnerAnimations[index]}`, () => {
      const component = shallow(
        <EfeSpinner animation={`${spinnerAnimations[index]}`} />
      );
      expect(
        component.find(`.efe-spinner-animation-${spinnerAnimations[index]}`)
      ).toHaveLength(1);
    });
  }
});

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

describe("Spinner Mode Test For Default Color", () => {
  for (let index = 0; index < spinnerModes.length; index++) {
    test(`Mode value: ${spinnerModes[index]}`, () => {
      const component = shallow(<EfeSpinner mode={spinnerModes[index]} />);
      expect(component.find(`.${spinnerModes[index]}-spinner`)).toHaveLength(1);
    });
  }
});

describe("Spinner Mode Test With Color Values", () => {
  for (let i = 0; i < spinnerModes.length; i++) {
    for (let j = 0; j < colors.length; j++) {
      test(`Mode value: ${spinnerModes[i]}, Color value: ${colors[j]}`, () => {
        const component = shallow(
          <EfeSpinner mode={spinnerModes[i]} color={colors[j]} />
        );
        expect(
          component.find(`.efe-spinner-${spinnerModes[i]}-${colors[j]}`)
        ).toHaveLength(1);
      });
    }
  }
});
