ldx-widgets
Version:
widgets
49 lines (29 loc) • 1.25 kB
text/coffeescript
describe 'IOSToggleSwitch', ->
React = require 'react'
IOSToggleSwitch = React.createFactory require('../../src/components/ios_toggle_switch')
_ = require 'lodash'
TestUtils = require 'react-addons-test-utils'
ReactDOM = require 'react-dom'
#--------------------------------------------------------------------- Input checked toggle
it 'Should return the opposite of the checked prop when getValue is called', ->
iosToggleSwitch = TestUtils.renderIntoDocument IOSToggleSwitch {
checked: yes
onChange: ->
}
inputChecked = iosToggleSwitch.getValue()
expect(inputChecked).to.equal(no)
iosToggleSwitch = TestUtils.renderIntoDocument IOSToggleSwitch {
checked: no
onChange: ->
}
inputChecked = iosToggleSwitch.getValue()
expect(inputChecked).to.equal(yes)
#--------------------------------------------------------------------- Click handling
it 'Should call the onChangee prop when clicked', ->
onClick = sinon.spy()
iosToggleSwitch = TestUtils.renderIntoDocument IOSToggleSwitch {
onChange: onClick
}
el = ReactDOM.findDOMNode(iosToggleSwitch)
TestUtils.Simulate.click el, {}
expect(onClick.calledOnce).to.equal(true)