Skip to content

Commit dc9633e

Browse files
committed
not to merge, just checking if memory leaks are the issue
1 parent d9630da commit dc9633e

3 files changed

Lines changed: 123 additions & 0 deletions

File tree

src/components/Editor/Project/Project.test.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,82 @@ import { MemoryRouter } from "react-router-dom";
99

1010
window.HTMLElement.prototype.scrollIntoView = jest.fn();
1111

12+
jest.mock("react-container-query", () => ({
13+
useContainerQuery: () => [{ "width-larger-than-720": false }, jest.fn()],
14+
}));
15+
1216
jest.mock("react-router-dom", () => ({
1317
...jest.requireActual("react-router-dom"),
1418
useNavigate: () => jest.fn(),
1519
}));
1620

1721
jest.mock("../../../utils/Notifications");
1822

23+
jest.mock("../Output/Output", () => ({
24+
__esModule: true,
25+
default: () => <div data-testid="output" />,
26+
}));
27+
28+
jest.mock("../../Menus/Sidebar/Sidebar", () => ({
29+
__esModule: true,
30+
default: ({ options = [] }) => (
31+
<div data-testid="sidebar">
32+
<button title="sidebar.expand" type="button" />
33+
{options.includes("settings") && (
34+
<button title="sidebar.settings" type="button" />
35+
)}
36+
</div>
37+
),
38+
}));
39+
40+
jest.mock("../EditorInput/EditorInput", () => ({
41+
__esModule: true,
42+
default: () => <div data-testid="editor-input" />,
43+
}));
44+
45+
jest.mock("../../ProjectBar/ProjectBar", () => ({
46+
__esModule: true,
47+
default: () => <div data-testid="default-project-bar" />,
48+
}));
49+
50+
jest.mock("../../ProjectBar/ScratchProjectBar", () => ({
51+
__esModule: true,
52+
default: () => <div data-testid="scratch-project-bar" />,
53+
}));
54+
55+
jest.mock("./ScratchContainer", () => ({
56+
__esModule: true,
57+
default: () => <iframe title="Scratch" />,
58+
}));
59+
60+
jest.mock("../../../utils/ResizableWithHandle", () => ({
61+
__esModule: true,
62+
default: ({
63+
children,
64+
className,
65+
defaultWidth,
66+
defaultHeight,
67+
handleDirection,
68+
minWidth,
69+
maxWidth,
70+
...props
71+
}) => (
72+
<div
73+
{...props}
74+
className={className}
75+
style={{
76+
width: defaultWidth,
77+
height: defaultHeight,
78+
minWidth,
79+
maxWidth,
80+
}}
81+
>
82+
<div className={`resizable-with-handle__handle--${handleDirection}`} />
83+
{children}
84+
</div>
85+
),
86+
}));
87+
1988
jest.useFakeTimers();
2089

2190
const user1 = {

src/components/Mobile/MobileProject/MobileProject.test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,32 @@ import { showSidebar } from "../../../redux/EditorSlice";
77

88
window.HTMLElement.prototype.scrollIntoView = jest.fn();
99

10+
jest.mock("../../Editor/EditorInput/EditorInput", () => ({
11+
__esModule: true,
12+
default: () => <div data-testid="editor-input" />,
13+
}));
14+
15+
jest.mock("../../Editor/Output/Output", () => ({
16+
__esModule: true,
17+
default: () => <div data-testid="output" />,
18+
}));
19+
20+
jest.mock("../MobileProjectBar/MobileProjectBar", () => ({
21+
__esModule: true,
22+
default: () => <div data-testid="mobile-project-bar" />,
23+
}));
24+
25+
jest.mock("../../Menus/Sidebar/Sidebar", () => ({
26+
__esModule: true,
27+
default: ({ options = [] }) => (
28+
<div data-testid="sidebar">
29+
{options.includes("settings") && (
30+
<button title="sidebar.settings" type="button" />
31+
)}
32+
</div>
33+
),
34+
}));
35+
1036
const middlewares = [];
1137
const mockStore = configureStore(middlewares);
1238

src/components/WebComponentProject/WebComponentProject.test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,34 @@ import { Provider } from "react-redux";
44
import configureStore from "redux-mock-store";
55
import WebComponentProject from "./WebComponentProject";
66

7+
jest.mock("react-responsive", () => ({
8+
useMediaQuery: () => false,
9+
}));
10+
11+
jest.mock("../Editor/Project/Project", () => ({
12+
__esModule: true,
13+
default: ({ withSidebar, sidebarOptions = [], withProjectbar }) => (
14+
<div data-testid="project">
15+
<div>output.textOutput</div>
16+
{withSidebar && <button title="sidebar.expand" type="button" />}
17+
{withSidebar && sidebarOptions.includes("settings") && (
18+
<button title="sidebar.settings" type="button" />
19+
)}
20+
{withProjectbar && <div>header.newProject</div>}
21+
</div>
22+
),
23+
}));
24+
25+
jest.mock("../Mobile/MobileProject/MobileProject", () => ({
26+
__esModule: true,
27+
default: () => <div data-testid="mobile-project">output.textOutput</div>,
28+
}));
29+
30+
jest.mock("../Editor/Output/Output", () => ({
31+
__esModule: true,
32+
default: () => <div data-testid="output">output.textOutput</div>,
33+
}));
34+
735
const codeChangedHandler = jest.fn();
836
const runStartedHandler = jest.fn();
937
const runCompletedHandler = jest.fn();

0 commit comments

Comments
 (0)