File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed
Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -173,12 +173,13 @@ const ToolsTab = ({
173173 name = { key }
174174 placeholder = { prop . description }
175175 value = { ( params [ key ] as string ) ?? "" }
176- onChange = { ( e ) =>
176+ onChange = { ( e ) => {
177+ const value = e . target . value ;
177178 setParams ( {
178179 ...params ,
179- [ key ] : Number ( e . target . value ) ,
180- } )
181- }
180+ [ key ] : value === "" ? "" : Number ( value ) ,
181+ } ) ;
182+ } }
182183 className = "mt-1"
183184 />
184185 ) : (
Original file line number Diff line number Diff line change @@ -111,6 +111,27 @@ describe("ToolsTab", () => {
111111 } ) ;
112112 } ) ;
113113
114+ it ( "should allow typing negative numbers" , async ( ) => {
115+ renderToolsTab ( {
116+ selectedTool : mockTools [ 0 ] ,
117+ } ) ;
118+
119+ const input = screen . getByRole ( "spinbutton" ) as HTMLInputElement ;
120+
121+ // Complete the negative number
122+ fireEvent . change ( input , { target : { value : "-42" } } ) ;
123+ expect ( input . value ) . toBe ( "-42" ) ;
124+
125+ const submitButton = screen . getByRole ( "button" , { name : / r u n t o o l / i } ) ;
126+ await act ( async ( ) => {
127+ fireEvent . click ( submitButton ) ;
128+ } ) ;
129+
130+ expect ( defaultProps . callTool ) . toHaveBeenCalledWith ( mockTools [ 0 ] . name , {
131+ num : - 42 ,
132+ } ) ;
133+ } ) ;
134+
114135 it ( "should disable button and change text while tool is running" , async ( ) => {
115136 // Create a promise that we can resolve later
116137 let resolvePromise : ( ( value : unknown ) => void ) | undefined ;
You can’t perform that action at this time.
0 commit comments