Skip to content

Commit 70ccb21

Browse files
committed
feat: add SiteEmbed test file
1 parent 2bb6704 commit 70ccb21

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { describe, expect, it } from "vitest";
2+
import { render, waitFor } from "../../../../test/src/react-render.js";
3+
import { TEST_CLIENT } from "../../../../test/src/test-clients.js";
4+
import { SiteEmbed } from "./SiteEmbed.js";
5+
6+
describe("SiteEmbed", () => {
7+
it("renders iframe with correct src", () => {
8+
const testUrl = "https://example.com/";
9+
const { container } = render(
10+
<SiteEmbed src={testUrl} client={TEST_CLIENT} />,
11+
);
12+
13+
const iframe = container.querySelector("iframe");
14+
expect(iframe).toBeTruthy();
15+
expect(iframe?.src).toBe(testUrl);
16+
});
17+
18+
it("throws error if clientId is not provided", () => {
19+
const testUrl = "https://example.com/";
20+
expect(() =>
21+
// biome-ignore lint/suspicious/noExplicitAny: testing invalid input
22+
render(<SiteEmbed src={testUrl} client={{} as any} />),
23+
).toThrow("The SiteEmbed client must have a clientId");
24+
});
25+
26+
it("adds wallet params to url when wallet is connected", async () => {
27+
const testUrl = "https://example.com/";
28+
const { container } = render(
29+
<SiteEmbed src={testUrl} client={TEST_CLIENT} />,
30+
{
31+
setConnectedWallet: true,
32+
},
33+
);
34+
35+
const iframe = container.querySelector("iframe");
36+
expect(iframe).toBeTruthy();
37+
await waitFor(() => expect(iframe?.src).toContain("walletId="));
38+
});
39+
});

0 commit comments

Comments
 (0)