Skip to content

Commit 9340bd8

Browse files
committed
test: add App → AppBridge integration test for downloadFile
1 parent f07bdfb commit 9340bd8

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/app-bridge.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,36 @@ describe("App <-> AppBridge integration", () => {
712712
expect(result.content).toEqual(resultContent);
713713
});
714714

715+
it("ondownloadfile setter registers handler for ui/download-file requests", async () => {
716+
const downloadParams = {
717+
contents: [
718+
{
719+
type: "resource" as const,
720+
resource: {
721+
uri: "file:///export.json",
722+
mimeType: "application/json",
723+
text: '{"key":"value"}',
724+
},
725+
},
726+
],
727+
};
728+
const receivedRequests: unknown[] = [];
729+
730+
bridge.ondownloadfile = async (params) => {
731+
receivedRequests.push(params);
732+
return {};
733+
};
734+
735+
await bridge.connect(bridgeTransport);
736+
await app.connect(appTransport);
737+
738+
const result = await app.downloadFile(downloadParams);
739+
740+
expect(receivedRequests).toHaveLength(1);
741+
expect(receivedRequests[0]).toMatchObject(downloadParams);
742+
expect(result).toEqual({});
743+
});
744+
715745
it("callServerTool throws a helpful error when called with a string instead of params object", async () => {
716746
await bridge.connect(bridgeTransport);
717747
await app.connect(appTransport);

0 commit comments

Comments
 (0)