Skip to content

Commit f373011

Browse files
committed
chore: add setup tests for App.tsx
1 parent b1100ce commit f373011

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

biome.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"clientKind": "git"
66
},
77
"files": {
8-
"includes": ["./src/**", "!src/client/gen/types.ts", "!pnpm-lock.yaml"],
8+
"includes": ["./**.config.ts","./src/**/*.{ts,tsx}", "!src/client/gen/types.ts", "!pnpm-lock.yaml"],
99
"ignoreUnknown": true
1010
},
1111
"linter": {

src/client/App.test.tsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
import type { EditorProps } from "@monaco-editor/react";
22
import { TooltipProvider } from "@radix-ui/react-tooltip";
3-
import { render, screen, waitFor } from "@testing-library/react";
3+
import {
4+
cleanup,
5+
render,
6+
screen,
7+
waitFor,
8+
} from "@testing-library/react";
49
import type { FC } from "react";
510
import { createBrowserRouter, RouterProvider } from "react-router";
6-
import { beforeEach, describe, expect, it, vi } from "vitest";
11+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
712
import { App } from "@/client/App";
813
import { EditorProvider } from "@/client/contexts/editor";
914
import { ThemeProvider } from "@/client/contexts/theme";
10-
import { initWasm } from "@/utils/wasm";
11-
import defaultExample from "@/examples/code/default.tf?raw";
1215
import attachGPUExample from "@/examples/code/attach-gpu.tf?raw";
16+
import defaultExample from "@/examples/code/default.tf?raw";
17+
import { initWasm } from "@/utils/wasm";
1318

1419
vi.mock("@/utils/wasm", async () => {
20+
const { getDynamicParametersOutput } = await import("@/utils/wasm");
1521
return {
1622
initWasm: vi
1723
.fn<typeof initWasm>(async () => {
@@ -22,7 +28,7 @@ vi.mock("@/utils/wasm", async () => {
2228
return "loaded";
2329
})
2430
.mockResolvedValue("loaded"),
25-
getDynamicParametersOutput: vi.fn(async () => null),
31+
getDynamicParametersOutput: vi.fn(getDynamicParametersOutput),
2632
};
2733
});
2834

@@ -31,7 +37,7 @@ vi.mock("@monaco-editor/react", () => ({
3137
<textarea
3238
data-testid="monaco-editor"
3339
value={value}
34-
onChange={(e) =>
40+
onChange={(e) => {
3541
onChange?.(e.target.value, {
3642
changes: [],
3743
eol: "\n",
@@ -40,8 +46,8 @@ vi.mock("@monaco-editor/react", () => ({
4046
isRedoing: false,
4147
isFlush: false,
4248
isEolChange: false,
43-
})
44-
}
49+
});
50+
}}
4551
{...props}
4652
/>
4753
),
@@ -73,6 +79,9 @@ describe("App - Initial State Setup", () => {
7379
delete window.go_preview;
7480
vi.clearAllMocks();
7581
});
82+
afterEach(() => {
83+
cleanup();
84+
});
7685

7786
it("should show the loading modal while the wasm module is loading", async () => {
7887
render(<TestApp />);
@@ -114,3 +123,4 @@ describe("App - Initial State Setup", () => {
114123
expect(screen.findByDisplayValue(attachGPUExample));
115124
});
116125
});
126+

src/client/hooks/debounce.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export function useDebouncedValue<T = unknown>(
9090

9191
useEffect(() => {
9292
setIsDebouncing(() => true);
93-
const timeoutId = window.setTimeout(() => {
93+
const timeoutId = setTimeout(() => {
9494
setDebouncedValue(value);
9595
setIsDebouncing(() => false);
9696
}, debounceTimeMs);

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
]
1818
}
1919
}
20-
}
20+
}

0 commit comments

Comments
 (0)