-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathScratchContainer.test.js
More file actions
44 lines (37 loc) · 1.21 KB
/
Copy pathScratchContainer.test.js
File metadata and controls
44 lines (37 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import configureStore from "redux-mock-store";
import { render, screen } from "@testing-library/react";
import React from "react";
import { Provider } from "react-redux";
import ScratchContainer from "./ScratchContainer";
describe("ScratchContainer", () => {
let originalAssetsUrl;
beforeEach(() => {
originalAssetsUrl = process.env.ASSETS_URL;
process.env.ASSETS_URL = "https://example.com";
});
afterEach(() => {
process.env.ASSETS_URL = originalAssetsUrl;
});
test("renders iframe with src built from project_id and api_url", () => {
const mockStore = configureStore([]);
const store = mockStore({
editor: {
project: {
identifier: "project-123",
},
scratchApiEndpoint: "https://api.example.com/v1",
},
});
render(
<Provider store={store}>
<ScratchContainer />
</Provider>,
);
const iframe = screen.getByTitle("Scratch");
expect(iframe).toBeInTheDocument();
const url = new URL(iframe.getAttribute("src"));
expect(url.pathname).toBe("/scratch.html");
expect(url.searchParams.get("project_id")).toBe("project-123");
expect(url.searchParams.get("api_url")).toBe("https://api.example.com/v1");
});
});