<commit_before>import React from 'react';
import { shallow } from 'enzyme';

import Radio from './Radio';

describe('Radio', () => {
  let component;

  beforeEach(() => {
    component = shallow(<Radio name="test-radio" />);
  });

  it('renders a hidden input that keeps and changes state', () => {
    const hiddenInput = () => component.find('input');
    expect(hiddenInput().prop('className')).toContain('sr-only');
    expect(hiddenInput().prop('name')).toBe('test-radio');
    expect(hiddenInput().prop('checked')).toBe(false);
    const onSelect = jest.fn();
    component.setProps({ selected: true, onSelect });
    expect(hiddenInput().prop('checked')).toBe(true);
    expect(onSelect).not.toHaveBeenCalled();
    hiddenInput().simulate('change');
    expect(onSelect).toHaveBeenCalledTimes(1);
    expect(onSelect).toHaveBeenCalledWith(false);
  });

  it('has a button that can also be clicked to change state', () => {
    const onSelect = jest.fn();
    component.setProps({ onSelect });
    expect(onSelect).not.toHaveBeenCalled();
    component.find('button').simulate('click');
    expect(onSelect).toHaveBeenCalledTimes(1);
    expect(onSelect).toHaveBeenCalledWith(true);
  });

  it('sets it to selected when the component is selected', () => {
    const componentSelected = () => component.find('div.tv-radio').hasClass('tv-radio--selected');
    expect(componentSelected()).toBe(false);
    component.setProps({ selected: true });
    expect(componentSelected()).toBe(true);
  });

  it('passes className to the main div', () => {
    expect(component.find('div.tv-radio').hasClass('test-class')).toBe(false);
    component.setProps({ className: 'test-class' });
    expect(component.find('div.tv-radio').hasClass('test-class')).toBe(true);
  });
});<commit_msg>add test for passing children<commit_after>import React from 'react';
import { shallow } from 'enzyme';

import Radio from './Radio';

describe('Radio', () => {
  let component;

  beforeEach(() => {
    component = shallow(<Radio name="test-radio" />);
  });

  it('renders a hidden input that keeps and changes state', () => {
    const hiddenInput = () => component.find('input');
    expect(hiddenInput().prop('className')).toContain('sr-only');
    expect(hiddenInput().prop('name')).toBe('test-radio');
    expect(hiddenInput().prop('checked')).toBe(false);
    const onSelect = jest.fn();
    component.setProps({ selected: true, onSelect });
    expect(hiddenInput().prop('checked')).toBe(true);
    expect(onSelect).not.toHaveBeenCalled();
    hiddenInput().simulate('change');
    expect(onSelect).toHaveBeenCalledTimes(1);
    expect(onSelect).toHaveBeenCalledWith(false);
  });

  it('has a button that can also be clicked to change state', () => {
    const onSelect = jest.fn();
    component.setProps({ onSelect });
    expect(onSelect).not.toHaveBeenCalled();
    component.find('button').simulate('click');
    expect(onSelect).toHaveBeenCalledTimes(1);
    expect(onSelect).toHaveBeenCalledWith(true);
  });

  it('sets it to selected when the component is selected', () => {
    const componentSelected = () => component.find('div.tv-radio').hasClass('tv-radio--selected');
    expect(componentSelected()).toBe(false);
    component.setProps({ selected: true });
    expect(componentSelected()).toBe(true);
  });

  it('passes className to the main div', () => {
    expect(component.find('div.tv-radio').hasClass('test-class')).toBe(false);
    component.setProps({ className: 'test-class' });
    expect(component.find('div.tv-radio').hasClass('test-class')).toBe(true);
  });

  it('renders children given to it', () => {
    const children = <div>I am a child yo</div>;
    component.setProps({ children });
    expect(component.contains(children)).toBe(true);
  });
});
{'fraction_non_alphanumeric': 0.18845950238221282, 'fraction_numerical': 0.0010587612493382743, 'mean_word_length': 4.581979320531758, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 24, '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': '2861823', 'n_tokens_mistral': 1104, 'n_tokens_neox': 1110, 'n_words': 207}