@@ -63,6 +63,72 @@ describe('InputNumber.Formatter', () => {
63
63
expect ( onChange ) . toHaveBeenCalledWith ( 100 ) ;
64
64
} ) ;
65
65
66
+ it ( 'formatter on IME numeric keypad input' , ( ) => {
67
+ const { container } = render (
68
+ < InputNumber formatter = { ( value ) => `${ value } ` . replace ( / \B (? = ( \d { 3 } ) + (? ! \d ) ) / g, ',' ) } />
69
+ ) ;
70
+ const input = container . querySelector ( 'input' ) ;
71
+ fireEvent . focus ( input ) ;
72
+ fireEvent . compositionStart ( input ) ;
73
+ fireEvent . keyDown ( input , {
74
+ which : 229 ,
75
+ key : 'Process' ,
76
+ code : 'Numpad1' ,
77
+ keyCode : 229 ,
78
+ composed : true ,
79
+ } ) ;
80
+ fireEvent . change ( input , { target : { value : '1' } } ) ;
81
+ fireEvent . keyDown ( input , {
82
+ which : 229 ,
83
+ key : 'Process' ,
84
+ code : 'Numpad2' ,
85
+ keyCode : 229 ,
86
+ composed : true ,
87
+ } ) ;
88
+ fireEvent . change ( input , { target : { value : '12' } } ) ;
89
+ fireEvent . keyDown ( input , {
90
+ which : 229 ,
91
+ key : 'Process' ,
92
+ code : 'Numpad3' ,
93
+ keyCode : 229 ,
94
+ composed : true ,
95
+ } ) ;
96
+ fireEvent . change ( input , { target : { value : '123' } } ) ;
97
+ fireEvent . keyDown ( input , {
98
+ which : 229 ,
99
+ key : 'Process' ,
100
+ code : 'Numpad4' ,
101
+ keyCode : 229 ,
102
+ composed : true ,
103
+ } ) ;
104
+ fireEvent . change ( input , { target : { value : '1234' } } ) ;
105
+ fireEvent . keyDown ( input , {
106
+ which : 229 ,
107
+ key : 'Process' ,
108
+ code : 'Enter' ,
109
+ keyCode : 229 ,
110
+ composed : true ,
111
+ } ) ;
112
+ fireEvent . compositionEnd ( input ) ;
113
+ fireEvent . blur ( input ) ;
114
+ expect ( input . value ) . toEqual ( '1,234' ) ;
115
+
116
+ fireEvent . focus ( input ) ;
117
+ fireEvent . compositionStart ( input ) ;
118
+ fireEvent . keyDown ( input , {
119
+ which : 229 ,
120
+ key : 'Process' ,
121
+ code : 'Numpad5' ,
122
+ keyCode : 229 ,
123
+ composed : true ,
124
+ } ) ;
125
+ fireEvent . change ( input , { target : { value : '12345' } } ) ;
126
+ fireEvent . compositionEnd ( input ) ;
127
+ fireEvent . change ( input , { target : { value : '1234' } } ) ;
128
+ fireEvent . blur ( input ) ;
129
+ expect ( input . value ) . toEqual ( '12,345' ) ;
130
+ } ) ;
131
+
66
132
it ( 'formatter and parser' , ( ) => {
67
133
const onChange = jest . fn ( ) ;
68
134
const { container } = render (
0 commit comments