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

mobileThemeRuntime.test.ts

51 lines1.4 KB

1import { describe, expect, it, vi } from "vite-plus/test";
2​
3vi.mock("react-native", () => ({ Platform: { OS: "ios" } }));
4​
5import {
6 createMobileThemeRuntimeOperations,
7 type MobileThemeRuntimeState,
8} from "./mobileThemeRuntime";
9​
10const initialState: MobileThemeRuntimeState = {
11 baseFontSize: 16,
12 fontId: "dm-sans",
13 monoFontId: "system",
14 themeAppearance: "light",
15 themeMode: "system",
16};
17​
18describe("mobileThemeRuntime", () => {
19 it("lets system appearance changes flow through the root ScopedTheme only", () => {
20 const operations = createMobileThemeRuntimeOperations(initialState, {
21 ...initialState,
22 themeAppearance: "dark",
23 });
24​
25 expect(operations).toEqual([]);
26 });
27​
28 it("swaps the font family variables when the font changes", () => {
29 const operations = createMobileThemeRuntimeOperations(initialState, {
30 ...initialState,
31 fontId: "system",
32 });
33​
34 expect(operations[0]).toMatchObject({
35 kind: "update-text-variables",
36 variables: { "--font-sans": "System", "--font-medium": "System", "--font-bold": "System" },
37 });
38 });
39​
40 it("swaps the mono family variable when the mono font changes", () => {
41 const operations = createMobileThemeRuntimeOperations(initialState, {
42 ...initialState,
43 monoFontId: "meslo",
44 });
45​
46 expect(operations[0]).toMatchObject({
47 kind: "update-text-variables",
48 variables: { "--font-mono": "MesloLGS-NF-Regular" },
49 });
50 });
51});