diff options
Diffstat (limited to 'test/react/Radio.spec.js')
-rw-r--r-- | test/react/Radio.spec.js | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/test/react/Radio.spec.js b/test/react/Radio.spec.js deleted file mode 100644 index 39e33f7..0000000 --- a/test/react/Radio.spec.js +++ /dev/null @@ -1,60 +0,0 @@ -import React from 'react'; -import Radio from '../../src/react/Radio.js'; - -import renderer from 'react-test-renderer'; -import {mount} from 'enzyme'; - -class RadioForm extends React.Component { - constructor(props) { - super(props); - this.state = {checked: false}; - - this.handleChange = this.handleChange.bind(this); - } - - handleChange(val) { - this.setState({checked: val}); - } - - getChecked() { - return this.radio.getChecked(); - } - - render() { - return ( - <form > - <Radio ref={(radio)=>{this.radio = radio;}} name='grp1' checked={this.state.checked} label='This is the radio label' value='1' onChange={this.handleChange} /> - </form> - ); - } -} - -describe('Radio', () => { - test('Radio - unchecked', () => { - const radio = renderer.create(<Radio name='grp4' label='This is the radio label' value='1' />).toJSON(); - expect(radio).toMatchSnapshot(); - }); - - test('Radio - disabled', () => { - const radio = renderer.create(<Radio name='grp2' disabled={true} label='This is the radio label' value='1' />).toJSON(); - expect(radio).toMatchSnapshot(); - }); - - test('Radio - checked state changes', () => { - const radio = mount(<RadioForm />); - expect(radio.instance().getChecked()).toEqual(false); - expect(radio.instance().getChecked()).toEqual(radio.find('input').props().checked); - radio.find('input').simulate('change', { target : { checked: true }}); - expect(radio.instance().getChecked()).toEqual(true); - expect(radio.instance().getChecked()).toEqual(radio.find('input').props().checked); - radio.find('input').simulate('change', { target : { checked: false }}); - expect(radio.instance().getChecked()).toEqual(false); - expect(radio.instance().getChecked()).toEqual(radio.find('input').props().checked); - }); - - test('Radio - returns its value', () => { - const radio = mount(<Radio label='This is the radio label' value='myVal' />); - expect(radio.instance().getValue()).toEqual('myVal'); - }); - -}); |