File tree 1 file changed +33
-0
lines changed
packages/ra-ui-materialui/src/input
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,39 @@ describe('<AutocompleteInput />', () => {
124
124
} ) ;
125
125
} ) ;
126
126
127
+ it ( 'should allow to clear the first character' , async ( ) => {
128
+ render (
129
+ < AdminContext dataProvider = { testDataProvider ( ) } >
130
+ < SimpleForm onSubmit = { jest . fn ( ) } defaultValues = { { role : 2 } } >
131
+ < AutocompleteInput
132
+ { ...defaultProps }
133
+ optionText = "foobar"
134
+ choices = { [
135
+ { id : 2 , foobar : 'foo' } ,
136
+ { id : 3 , foobar : 'bar' } ,
137
+ ] }
138
+ />
139
+ </ SimpleForm >
140
+ </ AdminContext >
141
+ ) ;
142
+
143
+ const input = screen . getByLabelText (
144
+ 'resources.users.fields.role'
145
+ ) as HTMLInputElement ;
146
+
147
+ fireEvent . focus ( input ) ;
148
+
149
+ userEvent . type ( input , 'f' ) ;
150
+ await waitFor ( ( ) => {
151
+ expect ( input . value ) . toEqual ( 'f' ) ;
152
+ } ) ;
153
+
154
+ userEvent . type ( input , '{backspace}' ) ;
155
+ await waitFor ( ( ) => {
156
+ expect ( input . value ) . toEqual ( '' ) ;
157
+ } ) ;
158
+ } ) ;
159
+
127
160
it ( 'should use optionText with a string value including "." as text identifier' , async ( ) => {
128
161
render (
129
162
< AdminContext dataProvider = { testDataProvider ( ) } >
You can’t perform that action at this time.
0 commit comments