@@ -33,3 +33,41 @@ describe.runIf(!!process.env.TW_SECRET_KEY)(
3333 } ) ;
3434 } ,
3535) ;
36+ import { describe , expect , it } from "vitest" ;
37+ import { render } from "../../../../test/src/react-render.js" ;
38+ import { TEST_CLIENT } from "../../../../test/src/test-clients.js" ;
39+ import { SiteEmbed } from "./SiteEmbed.js" ;
40+
41+ describe ( "SiteEmbed" , ( ) => {
42+ it ( "renders iframe with correct src" , ( ) => {
43+ const testUrl = "https://example.com" ;
44+ const { container } = render (
45+ < SiteEmbed src = { testUrl } client = { TEST_CLIENT } /> ,
46+ ) ;
47+
48+ const iframe = container . querySelector ( "iframe" ) ;
49+ expect ( iframe ) . toBeTruthy ( ) ;
50+ expect ( iframe ?. src ) . toBe ( testUrl ) ;
51+ } ) ;
52+
53+ it ( "throws error if clientId is not provided" , ( ) => {
54+ const testUrl = "https://example.com" ;
55+ expect ( ( ) =>
56+ render ( < SiteEmbed src = { testUrl } client = { { } as any } /> ) ,
57+ ) . toThrow ( "The SiteEmbed client must have a clientId" ) ;
58+ } ) ;
59+
60+ it ( "adds wallet params to url when wallet is connected" , async ( ) => {
61+ const testUrl = "https://example.com" ;
62+ const { container } = render (
63+ < SiteEmbed src = { testUrl } client = { TEST_CLIENT } /> ,
64+ {
65+ setConnectedWallet : true ,
66+ } ,
67+ ) ;
68+
69+ const iframe = container . querySelector ( "iframe" ) ;
70+ expect ( iframe ) . toBeTruthy ( ) ;
71+ expect ( iframe ?. src ) . toContain ( "walletId=" ) ;
72+ } ) ;
73+ } ) ;
0 commit comments