File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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 @@ -100,6 +100,9 @@ var MaskedInput = React.createClass({
100100 this . mask . selection . end = this . mask . selection . start + sizeDiff
101101 this . mask . backspace ( )
102102 }
103+ else {
104+ this . mask . setValue ( e . target . value )
105+ }
103106 var value = this . _getDisplayValue ( )
104107 e . target . value = value
105108 if ( value ) {
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
@@ -205,6 +206,28 @@ describe('MaskedInput', () => {
205206 cleanup ( el )
206207 } )
207208
209+ it ( 'should receive value from event.target in first argument of onChange callback' , ( ) => {
210+ const onChange = expect . createSpy ( )
211+ const el = setup ( )
212+ let ref = null
213+ ReactDOM . render (
214+ < MaskedInput
215+ ref = { ( r ) => {
216+ if ( r ) ref = r
217+ } }
218+ mask = "11.11.1111"
219+ onChange = { onChange }
220+ /> ,
221+ el
222+ )
223+ const input = ReactDOM . findDOMNode ( ref )
224+ TestUtils . Simulate . change ( input , { target : { value : '99.99.9999' } } )
225+
226+ expect ( onChange . calls [ 0 ] . arguments [ 0 ] . target . value ) . toEqual ( '99.99.9999' )
227+
228+ cleanup ( el )
229+ } )
230+
208231 it ( 'should handle updating multiple values' , ( ) => {
209232 const el = setup ( )
210233 let ref = null
You can’t perform that action at this time.
0 commit comments