Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

branding.test.ts

57 lines1.6 KB

1import { afterEach, describe, expect, it, vi } from "vitest";
2​
3const originalWindow = globalThis.window;
4​
5afterEach(() => {
6 vi.resetModules();
7​
8 if (originalWindow === undefined) {
9 Reflect.deleteProperty(globalThis, "window");
10 return;
11 }
12​
13 globalThis.window = originalWindow;
14});
15​
16describe("branding", () => {
17 it("uses injected desktop branding when available", async () => {
18 Object.defineProperty(globalThis, "window", {
19 configurable: true,
20 value: {
21 desktopBridge: {
22 getAppBranding: () => ({
23 baseName: "T3 Code",
24 stageLabel: "Nightly",
25 displayName: "T3 Code (Nightly)",
26 }),
27 },
28 },
29 });
30​
31 const branding = await import("./branding");
32​
33 expect(branding.APP_BASE_NAME).toBe("T3 Code");
34 expect(branding.APP_STAGE_LABEL).toBe("Nightly");
35 expect(branding.APP_DISPLAY_NAME).toBe("T3 Code (Nightly)");
36 });
37​
38 it("normalizes hosted app channel metadata", async () => {
39 vi.stubEnv("VITE_HOSTED_APP_CHANNEL", "nightly");
40​
41 const branding = await import("./branding");
42​
43 expect(branding.HOSTED_APP_CHANNEL).toBe("nightly");
44 expect(branding.HOSTED_APP_CHANNEL_LABEL).toBe("Nightly");
45 expect(branding.APP_STAGE_LABEL).toBe("Nightly");
46 expect(branding.APP_DISPLAY_NAME).toBe("T3 Code (Nightly)");
47 });
48​
49 it("ignores unknown hosted app channels", async () => {
50 vi.stubEnv("VITE_HOSTED_APP_CHANNEL", "preview");
51​
52 const branding = await import("./branding");
53​
54 expect(branding.HOSTED_APP_CHANNEL).toBeNull();
55 expect(branding.HOSTED_APP_CHANNEL_LABEL).toBeNull();
56 });
57});