@@ -71,29 +71,40 @@ describe('NumericInput onChange simulations', () => {
7171 groupSeparator : ' ' ,
7272 decimalSeparator : '.' ,
7373 } ,
74- value : '11111.22222'
74+ value : '11111.22222' ,
7575 } ) ;
7676 input . simulate ( 'change' , {
7777 nativeEvent : { target : { value : '9999999' } } ,
7878 } ) ;
7979 expect ( onChangeMock . mock . calls [ 0 ] [ 0 ] ) . toBe ( '9999999' ) ;
8080 } ) ;
81- test ( 'decimaal places cannot be removed if the decimalPlaces prop is passed to component' , ( ) => {
82- const { input, onChangeMock, wrapper } = mountNumericInputWithProps ( {
81+ test ( 'decimal places cannot be removed if the decimalPlaces prop is passed to component' , ( ) => {
82+ const { input, onChangeMock, wrapper } = mountNumericInputWithProps ( {
8383 bigNumberFormat : {
8484 groupSeparator : ' ' ,
8585 decimalSeparator : '.' ,
8686 } ,
8787 value : new BigNumber ( 111.222222 ) ,
88- decimalPlaces :6
88+ decimalPlaces : 6 ,
8989 } ) ;
9090 input . simulate ( 'change' , {
9191 nativeEvent : { target : { value : '9999999' } } ,
9292 } ) ;
93- console . log ( onChangeMock ) ;
94- console . log ( input . value ) ;
95- console . log ( wrapper ) ;
9693 expect ( onChangeMock . mock . calls [ 0 ] [ 0 ] ) . toBe ( '111.222222' ) ;
9794 } ) ;
95+ test ( 'it should be possible to replace a number with fixed decimalPlaces, with another number with fixed decimalPlaces' , ( ) => {
96+ const { input, onChangeMock, wrapper } = mountNumericInputWithProps ( {
97+ bigNumberFormat : {
98+ groupSeparator : ' ' ,
99+ decimalSeparator : '.' ,
100+ } ,
101+ value : new BigNumber ( 111.222222 ) ,
102+ decimalPlaces : 6 ,
103+ } ) ;
104+ input . simulate ( 'change' , {
105+ nativeEvent : { target : { value : '444.654321' } } ,
106+ } ) ;
107+ expect ( onChangeMock . mock . calls [ 0 ] [ 0 ] ) . toBe ( '444.654321' ) ;
108+ } ) ;
98109 } ) ;
99110} ) ;
0 commit comments