File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff 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 ) ;
You can’t perform that action at this time.
0 commit comments