Spaces:
Paused
Paused
Download console/src/utils/resolveLocalizedText.test.ts from mysticaldragon/HF: direct link, hf CLI and curl.
- Browser
- Download file 919 Bytes
-
https://huggingface.co/spaces/mysticaldragon/HF/resolve/main/console/src/utils/resolveLocalizedText.test.ts
- Command line
-
hf download hf://spaces/mysticaldragon/HF/console/src/utils/resolveLocalizedText.test.ts
-
curl -L -o resolveLocalizedText.test.ts https://huggingface.co/spaces/mysticaldragon/HF/resolve/main/console/src/utils/resolveLocalizedText.test.ts
919 Bytes
| import { describe, expect, it } from "vitest"; | |
| import { resolveLocalizedText } from "./resolveLocalizedText"; | |
| describe("resolveLocalizedText", () => { | |
| const dict = { | |
| en: "English", | |
| "zh-CN": "中文", | |
| }; | |
| it("returns empty for nullish", () => { | |
| expect(resolveLocalizedText(null, "zh")).toBe(""); | |
| expect(resolveLocalizedText(undefined, "en")).toBe(""); | |
| }); | |
| it("returns plain strings as-is", () => { | |
| expect(resolveLocalizedText("plain", "zh")).toBe("plain"); | |
| }); | |
| it("matches short UI lang to long dict key", () => { | |
| expect(resolveLocalizedText(dict, "zh")).toBe("中文"); | |
| }); | |
| it("matches exact locale", () => { | |
| expect(resolveLocalizedText(dict, "zh-CN")).toBe("中文"); | |
| expect(resolveLocalizedText(dict, "en")).toBe("English"); | |
| }); | |
| it("falls back to English when locale missing", () => { | |
| expect(resolveLocalizedText(dict, "ja")).toBe("English"); | |
| }); | |
| }); | |