@@ -442,15 +442,15 @@ describe("App <-> AppBridge integration", () => {
442442 await bridge . connect ( bridgeTransport ) ;
443443 } ) ;
444444
445- it ( "app.sendMessage triggers bridge.onmessage and returns result" , async ( ) => {
445+ it ( "app.message triggers bridge.onmessage and returns result" , async ( ) => {
446446 const receivedMessages : unknown [ ] = [ ] ;
447447 bridge . onmessage = async ( params ) => {
448448 receivedMessages . push ( params ) ;
449449 return { } ;
450450 } ;
451451
452452 await app . connect ( appTransport ) ;
453- const result = await app . sendMessage ( {
453+ const result = await app . message ( {
454454 role : "user" ,
455455 content : [ { type : "text" , text : "Hello from app" } ] ,
456456 } ) ;
@@ -463,46 +463,92 @@ describe("App <-> AppBridge integration", () => {
463463 expect ( result ) . toEqual ( { } ) ;
464464 } ) ;
465465
466- it ( "app.sendMessage returns error result when handler indicates error" , async ( ) => {
466+ it ( "app.message returns error result when handler indicates error" , async ( ) => {
467467 bridge . onmessage = async ( ) => {
468468 return { isError : true } ;
469469 } ;
470470
471471 await app . connect ( appTransport ) ;
472- const result = await app . sendMessage ( {
472+ const result = await app . message ( {
473473 role : "user" ,
474474 content : [ { type : "text" , text : "Test" } ] ,
475475 } ) ;
476476
477477 expect ( result . isError ) . toBe ( true ) ;
478478 } ) ;
479479
480- it ( "app.sendOpenLink triggers bridge.onopenlink and returns result" , async ( ) => {
480+ it ( "app.openLink triggers bridge.onopenlink and returns result" , async ( ) => {
481481 const receivedLinks : string [ ] = [ ] ;
482482 bridge . onopenlink = async ( params ) => {
483483 receivedLinks . push ( params . url ) ;
484484 return { } ;
485485 } ;
486486
487487 await app . connect ( appTransport ) ;
488- const result = await app . sendOpenLink ( { url : "https://example.com" } ) ;
488+ const result = await app . openLink ( { url : "https://example.com" } ) ;
489489
490490 expect ( receivedLinks ) . toEqual ( [ "https://example.com" ] ) ;
491491 expect ( result ) . toEqual ( { } ) ;
492492 } ) ;
493493
494- it ( "app.sendOpenLink returns error when host denies" , async ( ) => {
494+ it ( "app.openLink returns error when host denies" , async ( ) => {
495495 bridge . onopenlink = async ( ) => {
496496 return { isError : true } ;
497497 } ;
498498
499499 await app . connect ( appTransport ) ;
500- const result = await app . sendOpenLink ( { url : "https://blocked.com" } ) ;
500+ const result = await app . openLink ( { url : "https://blocked.com" } ) ;
501501
502502 expect ( result . isError ) . toBe ( true ) ;
503503 } ) ;
504504 } ) ;
505505
506+ describe ( "deprecated method aliases" , ( ) => {
507+ beforeEach ( async ( ) => {
508+ await bridge . connect ( bridgeTransport ) ;
509+ await app . connect ( appTransport ) ;
510+ } ) ;
511+
512+ it ( "app.sendMessage is an alias for app.message" , async ( ) => {
513+ expect ( app . sendMessage ) . toBe ( app . message ) ;
514+ } ) ;
515+
516+ it ( "app.sendOpenLink is an alias for app.openLink" , async ( ) => {
517+ expect ( app . sendOpenLink ) . toBe ( app . openLink ) ;
518+ } ) ;
519+
520+ it ( "bridge.sendResourceTeardown is an alias for bridge.resourceTeardown" , ( ) => {
521+ expect ( bridge . sendResourceTeardown ) . toBe ( bridge . resourceTeardown ) ;
522+ } ) ;
523+
524+ it ( "app.sendMessage works as deprecated alias" , async ( ) => {
525+ const receivedMessages : unknown [ ] = [ ] ;
526+ bridge . onmessage = async ( params ) => {
527+ receivedMessages . push ( params ) ;
528+ return { } ;
529+ } ;
530+
531+ await app . sendMessage ( {
532+ role : "user" ,
533+ content : [ { type : "text" , text : "Via deprecated alias" } ] ,
534+ } ) ;
535+
536+ expect ( receivedMessages ) . toHaveLength ( 1 ) ;
537+ } ) ;
538+
539+ it ( "app.sendOpenLink works as deprecated alias" , async ( ) => {
540+ const receivedLinks : string [ ] = [ ] ;
541+ bridge . onopenlink = async ( params ) => {
542+ receivedLinks . push ( params . url ) ;
543+ return { } ;
544+ } ;
545+
546+ await app . sendOpenLink ( { url : "https://example.com" } ) ;
547+
548+ expect ( receivedLinks ) . toEqual ( [ "https://example.com" ] ) ;
549+ } ) ;
550+ } ) ;
551+
506552 describe ( "ping" , ( ) => {
507553 it ( "App responds to ping from bridge" , async ( ) => {
508554 await bridge . connect ( bridgeTransport ) ;
0 commit comments