File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 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" : {
Original file line number Diff line number Diff line change 11/* eslint-env mocha */
22import React from 'react'
33import ReactDOM from 'react-dom'
4+ import TestUtils from 'react-addons-test-utils'
45import expect from 'expect'
56import 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
You can’t perform that action at this time.
0 commit comments