de103b113f
Route the terminal settings page's copy through i18next: the shell card, the font/font-size/link cards, and the section headings. Shell paths, font family names, and every select value stay untranslated — they are data compared with `===`. The font-category label and badge tables are module scope, so they hold catalog keys resolved at render rather than copy. Adds the three paths to `i18nGuardFiles` and the screen to the pseudo-coverage `SCREENS` list. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
51 lines
1.9 KiB
TypeScript
51 lines
1.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { t } from "@/lib/i18n";
|
|
import type { FontCategory } from "@/lib/terminal/terminal-font";
|
|
import { TERMINAL_FONT_PRESETS } from "@/lib/terminal/terminal-font";
|
|
import {
|
|
CATEGORY_BADGE_KEYS,
|
|
CATEGORY_LABEL_KEYS,
|
|
normalizeTerminalFontSize,
|
|
} from "./terminal-settings";
|
|
|
|
describe("normalizeTerminalFontSize", () => {
|
|
it("clamps finite font sizes to the supported range", () => {
|
|
expect(normalizeTerminalFontSize(6, 13)).toBe(8);
|
|
expect(normalizeTerminalFontSize(18, 13)).toBe(18);
|
|
expect(normalizeTerminalFontSize(30, 13)).toBe(24);
|
|
});
|
|
|
|
it("uses the fallback when the input is not finite", () => {
|
|
expect(normalizeTerminalFontSize(Number.NaN, 15)).toBe(15);
|
|
expect(normalizeTerminalFontSize(Number.POSITIVE_INFINITY, 15)).toBe(15);
|
|
});
|
|
});
|
|
|
|
describe("font category labels", () => {
|
|
const categories: FontCategory[] = ["icons", "ligatures", "system"];
|
|
|
|
it("holds catalog keys rather than copy", () => {
|
|
// The tables are module scope, so a `t()` call there would freeze at the
|
|
// boot locale. Keys must survive to render time — see docs/i18n.md.
|
|
for (const key of [
|
|
...Object.values(CATEGORY_LABEL_KEYS),
|
|
...Object.values(CATEGORY_BADGE_KEYS),
|
|
])
|
|
expect(key).toMatch(/^(settings|common):[a-zA-Z]+$/);
|
|
});
|
|
|
|
it("resolves every category the presets use", () => {
|
|
for (const category of categories) {
|
|
const label = t(CATEGORY_LABEL_KEYS[category]);
|
|
expect(label).not.toBe(CATEGORY_LABEL_KEYS[category]);
|
|
expect(label.length).toBeGreaterThan(0);
|
|
}
|
|
expect(t(CATEGORY_LABEL_KEYS.icons)).toBe("Nerd Fonts");
|
|
expect(t(CATEGORY_LABEL_KEYS.system)).toBe("System");
|
|
expect(t(CATEGORY_BADGE_KEYS.ligatures as string)).toBe("Ligatures");
|
|
|
|
const used = new Set(TERMINAL_FONT_PRESETS.map((preset) => preset.category));
|
|
for (const category of used) expect(CATEGORY_LABEL_KEYS[category]).toBeTruthy();
|
|
});
|
|
});
|