@@ -12,7 +12,7 @@ import {reduxForm as immutableReduxForm, reducer as immutableReducer} from 'redu
12
12
import { NumericField } from '../src'
13
13
import { NumericField as ImmutableNumericField } from '../src/immutable'
14
14
15
- const Input = ( { input : props } ) : React . Node => < input { ...props } / >
15
+ const Input = ( { input : inputProps , innerRef , ... props } ) : React . Node => < input { ...inputProps } { ... props } ref = { innerRef } / >
16
16
17
17
function min ( threshold : number ) : ( value : number ) => ?string {
18
18
return ( value : number ) => {
@@ -223,6 +223,31 @@ describe('NumericField', () => {
223
223
comp . update ( ) . find ( Input ) . simulate ( 'blur' )
224
224
expect ( comp . update ( ) . find ( 'input' ) . prop ( 'value' ) ) . to . equal ( 46.8 )
225
225
} )
226
+ it ( 'normalizes when enter is pressed' , ( ) => {
227
+ const store = createStore ( combineReducers ( { form : reducer } ) )
228
+
229
+ let input
230
+ const Form = reduxForm ( { form : 'form' } ) ( ( ) => (
231
+ < form >
232
+ < NumericField
233
+ name = "hello"
234
+ component = { Input }
235
+ innerRef = { c => input = c }
236
+ />
237
+ </ form >
238
+ ) )
239
+
240
+ const comp = mount (
241
+ < Provider store = { store } >
242
+ < Form />
243
+ </ Provider >
244
+ )
245
+
246
+ comp . find ( Input ) . simulate ( 'focus' )
247
+ comp . find ( Input ) . simulate ( 'change' , { target : { value : ' 23.4 ' } } )
248
+ comp . update ( ) . find ( Input ) . simulate ( 'keydown' , { keyCode : 13 } )
249
+ expect ( comp . update ( ) . find ( 'input' ) . prop ( 'value' ) ) . to . equal ( 23.4 )
250
+ } )
226
251
}
227
252
describe ( 'pojo' , ( ) => tests ( { NumericField, reducer, reduxForm} ) )
228
253
describe ( 'immutable' , ( ) => tests ( {
0 commit comments