Open History to see the last commit
1import type { DesktopPreviewTabState } from "@t3tools/contracts";
2import { describe, expect, it } from "vite-plus/test";
3
4import { projectDesktopState } from "./usePreviewBridge";
5
6const favicon = {
7 dataUrl: "data:image/png;base64,AAAA",
8 pageUrl: "http://localhost:3000/app",
9 capturedAt: 1,
10};
11
12function state(navStatus: DesktopPreviewTabState["navStatus"]): DesktopPreviewTabState {
13 return {
14 tabId: "tab-1",
15 webContentsId: 1,
16 navStatus,
17 canGoBack: false,
18 canGoForward: false,
19 zoomFactor: 1,
20 pictureInPicture: false,
21 colorScheme: "system",
22 controller: "none",
23 favicon,
24 updatedAt: "2026-08-09T00:00:00.000Z",
25 };
26}
27
28describe("projectDesktopState", () => {
29 it("shows a retained icon only while the current document has the captured origin", () => {
30 expect(
31 projectDesktopState(
32 state({ kind: "Loading", url: "http://localhost:3000/reload", title: "" }),
33 ).favicon,
34 ).toEqual(favicon);
35 expect(
36 projectDesktopState(
37 state({
38 kind: "LoadFailed",
39 url: "https://example.com/",
40 title: "",
41 code: -105,
42 description: "failed",
43 }),
44 ).favicon,
45 ).toBeNull();
46 expect(projectDesktopState(state({ kind: "Idle" })).favicon).toBeNull();
47 });
48});