Skip to content

Commit 2725e8d

Browse files
committed
add test for receiving value from event.target in onChange
1 parent e707bbd commit 2725e8d

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"eslint-config-jonnybuchanan": "2.0.3",
3939
"nwb": "0.9.x",
4040
"react": "15.x.x",
41+
"react-addons-test-utils": "15.x.x",
4142
"react-dom": "15.x.x"
4243
},
4344
"repository": {

tests/index-test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-env mocha */
22
import React from 'react'
33
import ReactDOM from 'react-dom'
4+
import TestUtils from 'react-addons-test-utils'
45
import expect from 'expect'
56
import MaskedInput from 'src'
67

@@ -132,5 +133,27 @@ describe('MaskedInput', () => {
132133

133134
cleanup(el)
134135
})
136+
137+
it('should receive value from event.target in first argument of onChange callback', () => {
138+
const onChange = expect.createSpy()
139+
const el = setup()
140+
let ref = null
141+
ReactDOM.render(
142+
<MaskedInput
143+
ref={(r) => {
144+
if (r) ref = r
145+
}}
146+
mask="11.11.1111"
147+
onChange={ onChange }
148+
/>,
149+
el
150+
)
151+
const input = ReactDOM.findDOMNode(ref)
152+
TestUtils.Simulate.change(input, { target: { value: '99.99.9999' } })
153+
154+
expect(onChange.calls[0].arguments[0].target.value).toEqual('99.99.9999')
155+
156+
cleanup(el)
157+
})
135158
})
136159

0 commit comments

Comments
 (0)