<commit_before>import React from 'react';
import { shallow } from 'enzyme';
import 'jest-styled-components';
import TestRenderer from 'react-test-renderer';
import { ColorSampleBox } from './color-sample-box.component';
import StyledColorSampleBox from './style/color-sample-box.style';
import classicTheme from '../../../../style/themes/classic';
import { assertStyleMatch } from '../../../../__spec_helper__/test-utils';
import StyledTickIcon from '../tick-icon/tick-icon.style';
import SmallTheme from '../../../../style/themes/small';
import MediumTheme from '../../../../style/themes/medium';
import LargeTheme from '../../../../style/themes/large';

function render(props) {
  return shallow(<ColorSampleBox color='#0073C2' { ...props } />);
}

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

describe('ColorSampleBox', () => {
  let wrapper;

  it('applies passed color to the background-color', () => {
    wrapper = renderStyles({ color: '#0073C2' });
    assertStyleMatch(
      {
        backgroundColor: '#0073C2'
      },
      wrapper.toJSON()
    );
  });

  describe('when checked', () => {
    it('renders no children', () => {
      const businessThemes = [SmallTheme, MediumTheme, LargeTheme];
      businessThemes.forEach((theme) => {
        wrapper = render({ theme, checked: true });
        expect(wrapper.children().exists()).toBeFalsy();
      });
    });
  });

  describe('when in classic theme', () => {
    describe('when color is set to transparent or none', () => {
      const colors = ['transparent', 'none'];
      it('applies border around the tile', () => {
        colors.forEach((color) => {
          wrapper = renderStyles({ theme: classicTheme, color });
        });
        assertStyleMatch(
          {
            borderColor: '#b3c2c8'
          },
          wrapper.toJSON()
        );
      });
    });

    describe('when checked', () => {
      it('renders the tick icon', () => {
        wrapper = render({ theme: classicTheme, checked: true });
        const icon = wrapper.find(StyledTickIcon);
        expect(icon.exists()).toBeTruthy();
        expect(icon.props().type).toEqual('tick');
      });
    });
  });
});
<commit_msg>fix color sample box spec file<commit_after>import React from 'react';
import { shallow } from 'enzyme';
import 'jest-styled-components';
import TestRenderer from 'react-test-renderer';
import { ColorSampleBox } from './color-sample-box.component';
import StyledColorSampleBox from './style/color-sample-box.style';
import classicTheme from '../../../../style/themes/classic';
import { assertStyleMatch } from '../../../../__spec_helper__/test-utils';
import StyledTickIcon from '../tick-icon/tick-icon.style';
import SmallTheme from '../../../../style/themes/small';
import MediumTheme from '../../../../style/themes/medium';
import LargeTheme from '../../../../style/themes/large';

function render(props) {
  return shallow(<ColorSampleBox color='#0073C2' { ...props } />);
}

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

describe('ColorSampleBox', () => {
  let wrapper;
  const businessThemes = [SmallTheme, MediumTheme, LargeTheme];

  it('applies passed color to the background-color', () => {
    wrapper = renderStyles({ color: '#0073C2' });
    assertStyleMatch(
      {
        backgroundColor: '#0073C2'
      },
      wrapper.toJSON()
    );
  });

  describe.each(businessThemes)(
    'when checked', (theme) => {
      it('renders no children', () => {
        wrapper = render({ theme, checked: true });
        expect(wrapper.children().exists()).toBeFalsy();
      });
    }
  );

  describe('when in classic theme', () => {
    describe('when color is set to transparent or none', () => {
      const colors = ['transparent', 'none'];
      it('applies border around the tile', () => {
        colors.forEach((color) => {
          wrapper = renderStyles({ theme: classicTheme, color });
        });
        assertStyleMatch(
          {
            borderColor: '#b3c2c8'
          },
          wrapper.toJSON()
        );
      });
    });

    describe('when checked', () => {
      it('renders the tick icon', () => {
        wrapper = render({ theme: classicTheme, checked: true });
        const icon = wrapper.find(StyledTickIcon);
        expect(icon.exists()).toBeTruthy();
        expect(icon.props().type).toEqual('tick');
      });
    });
  });
});

{'fraction_non_alphanumeric': 0.18427518427518427, 'fraction_numerical': 0.008041098950189859, 'mean_word_length': 2.7567114093959733, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2410004', 'n_tokens_mistral': 1293, 'n_tokens_neox': 1262, 'n_words': 284}