11import { render , screen , fireEvent } from "@testing-library/react" ;
22import { describe , it , expect , jest } from "@jest/globals" ;
3+ import "@testing-library/jest-dom" ;
34import ToolsTab from "../ToolsTab" ;
45import { Tool } from "@modelcontextprotocol/sdk/types.js" ;
56import { Tabs } from "@/components/ui/tabs" ;
@@ -16,6 +17,16 @@ describe("ToolsTab", () => {
1617 } ,
1718 } ,
1819 } ,
20+ {
21+ name : "tool3" ,
22+ description : "Integer tool" ,
23+ inputSchema : {
24+ type : "object" as const ,
25+ properties : {
26+ count : { type : "integer" as const } ,
27+ } ,
28+ } ,
29+ } ,
1930 {
2031 name : "tool2" ,
2132 description : "Second tool" ,
@@ -61,12 +72,31 @@ describe("ToolsTab", () => {
6172 // Switch to second tool
6273 rerender (
6374 < Tabs defaultValue = "tools" >
64- < ToolsTab { ...defaultProps } selectedTool = { mockTools [ 1 ] } />
75+ < ToolsTab { ...defaultProps } selectedTool = { mockTools [ 2 ] } />
6576 </ Tabs > ,
6677 ) ;
6778
6879 // Verify input is reset
6980 const newInput = screen . getByRole ( "spinbutton" ) as HTMLInputElement ;
7081 expect ( newInput . value ) . toBe ( "" ) ;
7182 } ) ;
83+ it ( "should handle integer type inputs" , ( ) => {
84+ renderToolsTab ( {
85+ selectedTool : mockTools [ 1 ] , // Use the tool with integer type
86+ } ) ;
87+
88+ const input = screen . getByRole ( "spinbutton" , {
89+ name : / c o u n t / i,
90+ } ) as HTMLInputElement ;
91+ expect ( input ) . toHaveProperty ( "type" , "number" ) ;
92+ fireEvent . change ( input , { target : { value : "42" } } ) ;
93+ expect ( input . value ) . toBe ( "42" ) ;
94+
95+ const submitButton = screen . getByRole ( "button" , { name : / r u n t o o l / i } ) ;
96+ fireEvent . click ( submitButton ) ;
97+
98+ expect ( defaultProps . callTool ) . toHaveBeenCalledWith ( mockTools [ 1 ] . name , {
99+ count : 42 ,
100+ } ) ;
101+ } ) ;
72102} ) ;
0 commit comments