fix(mui): type theme.colorSchemes access in theme.test.ts (tsc -b clean)

Define a minimal local interface for colorSchemes light/dark palettes and
assert the imported theme once via `as unknown as ThemeWithColorSchemes`,
replacing the 6 raw accesses that TypeScript rejected under tsc -b.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
BOHA
2026-06-06 19:23:23 +02:00
parent 859ae1a458
commit 6bc4a22338

View File

@@ -1,6 +1,23 @@
import { describe, it, expect } from "vitest";
import { theme } from "./theme";
/** Minimal palette shape used by the colorSchemes assertions below. */
interface SchemesPalette {
primary: { main: string };
background: { default: string; paper: string };
error: { main: string };
success: { main: string };
}
interface ColorScheme {
palette: SchemesPalette;
}
interface ThemeWithColorSchemes {
colorSchemes: { light: ColorScheme; dark: ColorScheme };
}
/** Single typed assertion so every `colorSchemes.*` access below is checked. */
const themedSchemes = (theme as unknown as ThemeWithColorSchemes).colorSchemes;
describe("MUI theme", () => {
it("uses the brand fonts", () => {
expect(theme.typography.fontFamily).toContain("Plus Jakarta Sans");
@@ -8,18 +25,18 @@ describe("MUI theme", () => {
});
it("maps the brand red per color scheme", () => {
expect(theme.colorSchemes.light.palette.primary.main).toBe("#c73030");
expect(theme.colorSchemes.dark.palette.primary.main).toBe("#d63031");
expect(themedSchemes.light.palette.primary.main).toBe("#c73030");
expect(themedSchemes.dark.palette.primary.main).toBe("#d63031");
});
it("maps the refreshed light canvas + paper", () => {
expect(theme.colorSchemes.light.palette.background.default).toBe("#f4f3f1");
expect(theme.colorSchemes.light.palette.background.paper).toBe("#ffffff");
expect(themedSchemes.light.palette.background.default).toBe("#f4f3f1");
expect(themedSchemes.light.palette.background.paper).toBe("#ffffff");
});
it("maps semantic colors per scheme", () => {
expect(theme.colorSchemes.light.palette.error.main).toBe("#b91c1c");
expect(theme.colorSchemes.dark.palette.success.main).toBe("#22c55e");
expect(themedSchemes.light.palette.error.main).toBe("#b91c1c");
expect(themedSchemes.dark.palette.success.main).toBe("#22c55e");
});
it("uses the base radius of 10", () => {