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

mobileThemeVariables.test.ts

58 lines2.2 KB

1import { describe, expect, it } from "vite-plus/test";
2​
3import { readDefaultMobileThemeVariables } from "./mobileTheme.test-support";
4import { getMobileThemeVariables, MOBILE_THEME_IDS, themeColorWithAlpha } from "./mobileTheme";
5import { getMobileThemeRuntimeVariables } from "./mobileThemeVariables";
6​
7describe("mobile theme runtime variables", () => {
8 it("derives the standard runtime palette from global.css", () => {
9 expect(getMobileThemeRuntimeVariables("t3-code", "light", "ios")).toEqual(
10 readDefaultMobileThemeVariables("light"),
11 );
12 expect(getMobileThemeRuntimeVariables("t3-code", "dark", "ios")).toEqual(
13 readDefaultMobileThemeVariables("dark"),
14 );
15 });
16​
17 it("uses the same shared palette source as generated custom themes", () => {
18 expect(getMobileThemeRuntimeVariables("ocean", "light", "ios")).toEqual(
19 getMobileThemeVariables("ocean", "light"),
20 );
21 expect(getMobileThemeRuntimeVariables("iris", "dark", "ios")).toEqual(
22 getMobileThemeVariables("iris", "dark"),
23 );
24 });
25​
26 it.each(MOBILE_THEME_IDS)(
27 "keeps %s colors on Android with an opaque Material frame",
28 (themeId) => {
29 for (const appearance of ["light", "dark"] as const) {
30 const ios = getMobileThemeRuntimeVariables(themeId, appearance, "ios");
31 const android = getMobileThemeRuntimeVariables(themeId, appearance, "android");
32 expect(android).toEqual({
33 ...ios,
34 "--color-header": themeColorWithAlpha(
35 ios[
36 themeId === "t3-code" || themeId === "material-you"
37 ? "--color-card"
38 : "--color-drawer"
39 ],
40 1,
41 ),
42 });
43 expect(android["--color-header"]).toMatch(/^rgba\(\d+, \d+, \d+, 1\)$/);
44 }
45 },
46 );
47​
48 it.each(["t3-code", "material-you"] as const)(
49 "keeps the %s default dark frame distinct from the rounded settings body",
50 (themeId) => {
51 const variables = getMobileThemeRuntimeVariables(themeId, "dark", "android");
52 expect(variables["--color-header"]).toBe("rgba(23, 23, 23, 1)");
53 expect(variables["--color-header"]).not.toBe(
54 themeColorWithAlpha(variables["--color-sheet-solid"], 1),
55 );
56 },
57 );
58});