<commit_before>/* global describe, expect, it */

import React from 'react'
import Checkbox from '../'
import {createRenderer} from 'react-addons-test-utils'

describe('Checkbox', () => {
  it('should render a simple example', () => {
    let renderer = createRenderer()
    renderer.render(<Checkbox onChange={() => {}} />)
    let box = renderer.getRenderOutput()
    expect(box).toBeTruthy()
  })

  it('should not be checked by default', () => {
    let renderer = createRenderer()
    renderer.render(<Checkbox onChange={() => {}} />)
    let box = renderer.getRenderOutput()
    expect(box.props.children[0].props.checked).toBe(false)
  })

  it('should render a checked checkbox', () => {
    let renderer = createRenderer()
    renderer.render(<Checkbox checked onChange={() => {}} />)
    let box = renderer.getRenderOutput()
    expect(box.props.children[0].props.checked).toBe(true)
  })

  it('should render a disabled checkbox', () => {
    let renderer = createRenderer()
    renderer.render(<Checkbox disabled onChange={() => {}} />)
    let box = renderer.getRenderOutput()
    expect(box.props.children[0].props.disabled).toBe(true)
  })

  it('should have a default label', () => {
    let renderer = createRenderer()
    renderer.render(<Checkbox onChange={() => {}} />)
    let box = renderer.getRenderOutput()
    expect(box.props.children[3].props.children).toBe('Label')
  })

  it('should render a custom label', () => {
    let renderer = createRenderer()
    renderer.render(<Checkbox label='custom label' onChange={() => {}} />)
    let box = renderer.getRenderOutput()
    expect(box.props.children[3].props.children).toBe('custom label')
  })

  it('should toggle between true and false when clicked', () => {
    let renderer = createRenderer()
    let changed = false
    let change = () => {
      changed = true
    }
    renderer.render(<Checkbox onChange={change} />)
    let box = renderer.getRenderOutput()
    box.props.children[0].props.onChange()
    expect(changed).toBe(true)
  })
})<commit_msg>checkbox: rewrite tests using enzyme<commit_after>/* global describe, expect, it */

import React from 'react'
import {shallow} from 'enzyme'
import Checkbox from '../'

describe('Checkbox', () => {
  it('should render a simple example', () => {
    const wrapper = shallow(<Checkbox onChange={() => {}} />)
    expect(wrapper.find('.Checkbox').length).toBe(1)
  })

  it('should not be checked by default', () => {
    const wrapper = shallow(<Checkbox onChange={() => {}} />)
    expect(wrapper.find('.Checkbox-input').props().checked).toBe(false)
  })

  it('should render a checked checkbox', () => {
    const wrapper = shallow(<Checkbox checked onChange={() => {}} />)
    expect(wrapper.find('.Checkbox-input').props().checked).toBe(true)
  })

  it('should render a disabled checkbox', () => {
    const wrapper = shallow(<Checkbox disabled onChange={() => {}} />)
    expect(wrapper.find('.Checkbox-input').props().disabled).toBe(true)
  })

  it('should have a default label', () => {
    const wrapper = shallow(<Checkbox onChange={() => {}} />)
    expect(wrapper.find('.Checkbox-label').text()).toBe('Label')
  })

  it('should render a custom label', () => {
    const wrapper = shallow(<Checkbox label='custom label' onChange={() => {}} />)
    expect(wrapper.find('.Checkbox-label').text()).toBe('custom label')
  })

  it('should callback when clicked', (done) => {
    const change = () => done()
    const wrapper = shallow(<Checkbox onChange={change} />)
    wrapper.find('.Checkbox-input').simulate('change')
  })
})
{'fraction_non_alphanumeric': 0.18802462227196418, 'fraction_numerical': 0.00195858981533296, 'mean_word_length': 3.824561403508772, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 47, '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': '2226962', 'n_tokens_mistral': 1071, 'n_tokens_neox': 1060, 'n_words': 232}