Files
kandev/apps/web/lib/config.test.ts
T
2026-06-18 18:36:48 +01:00

34 lines
963 B
TypeScript

import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
describe("isDebugUI", () => {
beforeEach(() => {
vi.resetModules();
});
afterEach(() => {
vi.unstubAllEnvs();
vi.unstubAllGlobals();
});
it("is true when window.__KANDEV_DEBUG is set at runtime", async () => {
vi.stubEnv("VITE_KANDEV_DEBUG", "");
vi.stubGlobal("window", { __KANDEV_DEBUG: true });
const { isDebugUI } = await import("./config");
expect(isDebugUI()).toBe(true);
});
it("is false in production with no flags", async () => {
vi.stubEnv("VITE_KANDEV_DEBUG", "");
vi.stubGlobal("window", {});
const { isDebugUI } = await import("./config");
expect(isDebugUI()).toBe(false);
});
it("is true when VITE_KANDEV_DEBUG=true", async () => {
vi.stubEnv("VITE_KANDEV_DEBUG", "true");
vi.stubGlobal("window", {});
const { isDebugUI } = await import("./config");
expect(isDebugUI()).toBe(true);
});
});