File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,26 @@ describe("ComboBox", () => {
6969 expect ( screen . getByRole ( "textbox" ) ) . toHaveValue ( "" ) ;
7070 } ) ;
7171
72+ it ( "should handle clear selection via keyboard navigation" , async ( ) => {
73+ const consoleLog = vi . spyOn ( console , "log" ) ;
74+ render ( ComboBox , {
75+ props : {
76+ selectedId : "1" ,
77+ value : "Email" ,
78+ } ,
79+ } ) ;
80+
81+ const clearButton = screen . getByRole ( "button" , {
82+ name : / c l e a r / i,
83+ } ) ;
84+ clearButton . focus ( ) ;
85+ expect ( clearButton ) . toHaveFocus ( ) ;
86+ await user . keyboard ( "{Enter}" ) ;
87+
88+ expect ( consoleLog ) . toHaveBeenCalledWith ( "clear" , expect . any ( String ) ) ;
89+ expect ( screen . getByRole ( "textbox" ) ) . toHaveValue ( "" ) ;
90+ } ) ;
91+
7292 it ( "should use custom translations when translateWithId is provided" , ( ) => {
7393 const customTranslations = {
7494 clearSelection : "Remove selected item" ,
You can’t perform that action at this time.
0 commit comments