The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { afterEach, describe, expect, it, vi } from "vite-plus/test"; |
| 2 | |
| 3 | import { navigateAfterThreadDeletion } from "./useThreadActions"; |
| 4 | import { toastManager } from "../components/ui/toast"; |
| 5 | |
| 6 | describe("navigateAfterThreadDeletion", () => { |
| 7 | afterEach(() => vi.restoreAllMocks()); |
| 8 | |
| 9 | it("reports a rejected navigation without failing the completed deletion", async () => { |
| 10 | const addToast = vi.spyOn(toastManager, "add").mockReturnValue("navigation-error"); |
| 11 | |
| 12 | await expect( |
| 13 | navigateAfterThreadDeletion(() => Promise.reject(new Error("route unavailable"))), |
| 14 | ).resolves.toBeUndefined(); |
| 15 | |
| 16 | expect(addToast).toHaveBeenCalledOnce(); |
| 17 | expect(addToast).toHaveBeenCalledWith( |
| 18 | expect.objectContaining({ |
| 19 | title: "Thread deleted, but navigation failed", |
| 20 | description: "route unavailable", |
| 21 | }), |
| 22 | ); |
| 23 | }); |
| 24 | }); |