All files / radiobutton/__tests__ Radiobutton-test.js

100% Statements 14/14
100% Branches 0/0
75% Functions 3/4
100% Lines 14/14
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 46 47 48 49 50 51 52 53 54    1x 1x 1x 1x   1x   1x 1x 1x 1x     1x 1x     1x 1x 1x                                                                
/* global it, describe */
 
import assert from 'assert'
import React from 'react'
import Radiobutton from '../'
import {mount} from 'enzyme'
 
const noop = () => {}
 
describe('Radiobutton', () => {
  it('should render a simple example', () => {
    const wrapper = mount(<Radiobutton name='test' onChange={noop} />)
    assert.equal(wrapper.find(Radiobutton).length, 1)
  })
 
  it('should render given items', () => {
    const wrapper = mount(
      <Radiobutton name='test' items={['Dog', 'Cat', 'Mouse']} onChange={noop} />
    )
    const buttons = wrapper.find(Radiobutton)
    assert.equal(buttons.length, 1)
    assert.equal(buttons.text(), 'DogCatMouse')
  })
 
  // it('should select given radio button', () => {
  //   const wrapper = mount(
  //     <Radiobutton
  //       name='test'
  //       items={['rb-Dog', 'rb-Cat', 'rb-Mouse']}
  //       selectedValue='rb-Mouse'
  //       onChange={noop}
  //     />
  //   )
  //   // cannot use class to find element since enzyme does not work with svg at the moment
  //   expect(wrapper.find('[value="rb-Mouse"]').node.checked).toBe(true)
  // })
 
  // it('should callback with current index on change event', (done) => {
  //   const callback = (item) => {
  //     expect(item).toEqual('rb-Dog')
  //     done()
  //   }
  //   const wrapper = mount(
  //     <Radiobutton
  //       name='test'
  //       items={['rb-Dog', 'rb-Cat', 'rb-Mouse']}
  //       selectedValue='rb-Mouse'
  //       onChange={callback}
  //     />
  //   )
  //   wrapper.find('[value="rb-Dog"]').simulate('change')
  // })
})