All files / checkbox/__tests__ Checkbox-test.js

100% Statements 28/28
100% Branches 0/0
60% Functions 9/15
100% Lines 27/27
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45    1x 1x 1x 1x   1x 1x 1x 1x     1x 1x 1x     1x 1x 1x     1x 1x 1x     1x 1x 1x     1x 1x 1x     1x 1x 1x 1x      
/* global describe, it */
 
import assert from 'assert'
import React from 'react'
import {shallow} from 'enzyme'
import Checkbox from '../'
 
describe('Checkbox', () => {
  it('should render a simple example', () => {
    const wrapper = shallow(<Checkbox onChange={() => {}} />)
    assert.equal(wrapper.find('.Checkbox').length, 1)
  })
 
  it('should not be checked by default', () => {
    const wrapper = shallow(<Checkbox onChange={() => {}} />)
    assert(!wrapper.find('.Checkbox-input').props().checked)
  })
 
  it('should render a checked checkbox', () => {
    const wrapper = shallow(<Checkbox checked onChange={() => {}} />)
    assert(wrapper.find('.Checkbox-input').props().checked)
  })
 
  it('should render a disabled checkbox', () => {
    const wrapper = shallow(<Checkbox disabled onChange={() => {}} />)
    assert(wrapper.find('.Checkbox-input').props().disabled)
  })
 
  it('should have a default label', () => {
    const wrapper = shallow(<Checkbox onChange={() => {}} />)
    assert.equal(wrapper.find('.Checkbox-label').text(), 'Label')
  })
 
  it('should render a custom label', () => {
    const wrapper = shallow(<Checkbox label='custom label' onChange={() => {}} />)
    assert(wrapper.find('.Checkbox-label').text(), 'custom label')
  })
 
  it('should callback when clicked', (done) => {
    const change = () => done()
    const wrapper = shallow(<Checkbox onChange={change} />)
    wrapper.find('.Checkbox-input').simulate('change')
  })
})