UNPKG

@activecollab/components

Version:

ActiveCollab Components

58 lines 2.05 kB
import { DEFAULT_DARK_THEME, DEFAULT_THEME, DARK_THEME_NAMES, LIGHT_THEME_NAMES, THEME_MODE_SINGLE, THEME_MODE_SYSTEM, resolveTheme } from "./themes"; describe("resolveTheme", () => { it("should split the theme list into light and dark without overlap", () => { expect(LIGHT_THEME_NAMES).toEqual(["indigo", "cupcake", "classic"]); expect(DARK_THEME_NAMES).toEqual(["neon", "dracula", "one-dark"]); }); it("should ignore the system appearance in single mode", () => { const selection = { mode: THEME_MODE_SINGLE, theme: "dracula", themeLight: "cupcake", themeDark: "one-dark" }; expect(resolveTheme(selection, false)).toBe("dracula"); expect(resolveTheme(selection, true)).toBe("dracula"); }); it("should follow the system appearance in system mode", () => { const selection = { mode: THEME_MODE_SYSTEM, theme: "dracula", themeLight: "cupcake", themeDark: "one-dark" }; expect(resolveTheme(selection, false)).toBe("cupcake"); expect(resolveTheme(selection, true)).toBe("one-dark"); }); it("should fall back to the defaults when a slot is missing or unknown", () => { expect(resolveTheme({ mode: THEME_MODE_SYSTEM }, false)).toBe(DEFAULT_THEME); expect(resolveTheme({ mode: THEME_MODE_SYSTEM }, true)).toBe(DEFAULT_DARK_THEME); expect(resolveTheme({ mode: THEME_MODE_SYSTEM, themeLight: "solarized", themeDark: "solarized" }, false)).toBe(DEFAULT_THEME); expect(resolveTheme({ mode: THEME_MODE_SYSTEM, themeLight: "solarized", themeDark: "solarized" }, true)).toBe(DEFAULT_DARK_THEME); expect(resolveTheme({ theme: "solarized" }, false)).toBe(DEFAULT_THEME); }); it("should treat an absent or unrecognised mode as single", () => { expect(resolveTheme({ theme: "neon" }, false)).toBe("neon"); expect(resolveTheme({ mode: "auto", theme: "neon" }, true)).toBe("neon"); }); }); //# sourceMappingURL=themes.test.js.map