Skip to content

Commit fb9124e

Browse files
author
sergey-ermakovich
committed
Assert all required params in the contract test
1 parent 5292b20 commit fb9124e

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

test/tools.test.mjs

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

2020
const EXPECTED = {
21-
hasdata_google_travel_flights_getGoogleFlights: 'departureId',
21+
hasdata_google_travel_flights_getGoogleFlights: ['departureId', 'arrivalId', 'outboundDate'],
2222
};
2323

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

0 commit comments

Comments
 (0)