import React from 'react';
import TestRenderer from 'react-test-renderer';
import 'jest-styled-components';
import { shallow } from 'enzyme';
import Spinner from './spinner.component';
import StyledSpinner from './spinner.style';
import OptionsHelper from '../../utils/helpers/options-helper';
import { assertStyleMatch } from '../../__spec_helper__/test-utils';
import { classicSpinnerColors, classicSpinnerSizes } from './classicSpinnerValues';

function render(props) {
  return shallow(<Spinner { ...props } />);
}

function renderStyles(props) {
  return TestRenderer.create(<StyledSpinner { ...props } />);
}

describe('Spinner', () => {
  let wrapper;
  it('renders as expected', () => {
    wrapper = render();
    expect(wrapper).toMatchSnapshot();
  });

  it('contains custom className if passed as a prop', () => {
    wrapper = render({ className: 'class' });
    expect(wrapper.find('.class').exists()).toEqual(true);
  });

  it('applies color reflecting type if passed', () => {
    OptionsHelper.colors.map((type) => {
      wrapper = renderStyles({ type });
      assertStyleMatch(
        {
          borderTopColor: classicSpinnerColors[type].borderTop,
          borderBottomColor: classicSpinnerColors[type].borderBottom,
          borderRightColor: classicSpinnerColors[type].borderRight,
          borderLeftColor: classicSpinnerColors[type].borderLeft
        },
        wrapper.toJSON()
      );
    });
  });

  it('applies width, height and border-width dependent on the passed size', () => {
    OptionsHelper.sizesFull.map((size) => {
      wrapper = renderStyles({ size });
      assertStyleMatch(
        {
          width: classicSpinnerSizes[size].width,
          height: classicSpinnerSizes[size].height,
          borderWidth: classicSpinnerSizes[size].borderWidth
        },
        wrapper.toJSON()
      );
    });
  });
});

@@ -924,32 +924,77 @@
 l(true);%0A  %7D);%0A%0A
+  OptionsHelper.colors.forEach((type) =%3E %7B%0A  
   it('applies co
@@ -1037,49 +1037,8 @@
 %3E %7B%0A
-    OptionsHelper.colors.map((type) =%3E %7B%0A
     
@@ -1430,24 +1430,72 @@
  %7D);%0A  %7D);%0A%0A
+  OptionsHelper.sizesFull.forEach((size) =%3E %7B%0A  
   it('applie
@@ -1570,52 +1570,8 @@
 %3E %7B%0A
-    OptionsHelper.sizesFull.map((size) =%3E %7B%0A
     

change map to foreach