Skip to content

Commit 5cc5452

Browse files
author
sergey-ermakovich
committed
Assert all required params in the contract test
1 parent f8c1fee commit 5cc5452

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

test/tools.test.mjs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ const KEY = process.env.HASDATA_API_KEY;
1818
const TIMEOUT_MS = 30_000;
1919

2020
const EXPECTED = {
21-
hasdata_booking_search_getBookingSearchResults: 'keyword',
22-
hasdata_booking_place_getBookingPlaceDetails: 'url',
21+
hasdata_booking_search_getBookingSearchResults: ['keyword', 'checkInDate', 'checkOutDate', 'rooms', 'adults', 'children'],
22+
hasdata_booking_place_getBookingPlaceDetails: ['url', 'checkInDate', 'checkOutDate', 'rooms', 'adults', 'children'],
2323
};
2424

2525
// A streamable HTTP body arrives either as plain JSON or as server-sent events. One SSE event
@@ -106,10 +106,12 @@ test('every tool still declares its required parameter', live, async () => {
106106
const required = tool.inputSchema?.required ?? [];
107107
const want = EXPECTED[tool.name];
108108
assert.ok(want, `tool ${tool.name} is not covered by this test`);
109-
assert.ok(
110-
required.includes(want),
111-
`${tool.name} should require ${want}, declares: ${required.join(', ') || 'nothing'}`
112-
);
109+
for (const param of want) {
110+
assert.ok(
111+
required.includes(param),
112+
`${tool.name} should require ${param}, declares: ${required.join(', ') || 'nothing'}`
113+
);
114+
}
113115
}
114116
});
115117

0 commit comments

Comments
 (0)