-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathWorkspaceFileTree.test.tsx
More file actions
35 lines (29 loc) · 1001 Bytes
/
WorkspaceFileTree.test.tsx
File metadata and controls
35 lines (29 loc) · 1001 Bytes
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
import { renderToStaticMarkup } from "react-dom/server";
import { useQuery } from "@tanstack/react-query";
import { beforeEach, describe, expect, it, vi } from "vitest";
vi.mock("@tanstack/react-query", async (importOriginal) => {
const actual = await importOriginal<typeof import("@tanstack/react-query")>();
return {
...actual,
useQuery: vi.fn(),
};
});
const useQueryMock = vi.mocked(useQuery);
describe("WorkspaceFileTree", () => {
beforeEach(() => {
useQueryMock.mockReset();
});
it("does not crash when the directory query returns a partial payload", async () => {
useQueryMock.mockReturnValue({
data: { truncated: false },
isError: false,
isLoading: false,
error: null,
} as never);
const { WorkspaceFileTree } = await import("./WorkspaceFileTree");
const markup = renderToStaticMarkup(
<WorkspaceFileTree cwd="/repo/project" resolvedTheme="light" />,
);
expect(markup).toContain("No files found.");
});
});