aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/client/App.test.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/App.test.tsx')
-rw-r--r--src/client/App.test.tsx25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/client/App.test.tsx b/src/client/App.test.tsx
index 516cbeb..bdc281a 100644
--- a/src/client/App.test.tsx
+++ b/src/client/App.test.tsx
@@ -15,6 +15,14 @@ vi.mock("./api/client", () => ({
logout: vi.fn(),
isAuthenticated: vi.fn(),
getTokens: vi.fn(),
+ getAuthHeader: vi.fn(),
+ rpc: {
+ api: {
+ decks: {
+ $get: vi.fn(),
+ },
+ },
+ },
},
ApiClientError: class ApiClientError extends Error {
constructor(
@@ -28,6 +36,12 @@ vi.mock("./api/client", () => ({
},
}));
+// Helper to create mock responses compatible with Hono's ClientResponse
+// biome-ignore lint/suspicious/noExplicitAny: Test helper needs flexible typing
+function mockResponse(data: { ok: boolean; status?: number; json: () => Promise<any> }) {
+ return data as unknown as Awaited<ReturnType<typeof apiClient.rpc.api.decks.$get>>;
+}
+
function renderWithRouter(path: string) {
const { hook } = memoryLocation({ path, static: true });
return render(
@@ -58,12 +72,21 @@ describe("App routing", () => {
refreshToken: "refresh-token",
});
vi.mocked(apiClient.isAuthenticated).mockReturnValue(true);
+ vi.mocked(apiClient.getAuthHeader).mockReturnValue({
+ Authorization: "Bearer access-token",
+ });
+ vi.mocked(apiClient.rpc.api.decks.$get).mockResolvedValue(
+ mockResponse({
+ ok: true,
+ json: async () => ({ decks: [] }),
+ }),
+ );
});
it("renders home page at /", () => {
renderWithRouter("/");
expect(screen.getByRole("heading", { name: "Kioku" })).toBeDefined();
- expect(screen.getByText("Spaced repetition learning app")).toBeDefined();
+ expect(screen.getByRole("heading", { name: "Your Decks" })).toBeDefined();
});
});