Files
rf4-spotter/apps/web/tests/unit/presentation.test.ts
T
2026-09-12 15:30:40 +07:00

37 lines
1.8 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import { activityLevel, plural } from "../../src/lib/presentation.ts";
import { fishVisualFamily } from "../../src/lib/fish-visuals.ts";
import { tackleVisualKind, tackleVisualTone } from "../../src/lib/tackle-visuals.ts";
test("activity levels share one complete 0-100 scale", () => {
assert.deepEqual(
[0, 39, 40, 59, 60, 79, 80, 100].map(score => activityLevel(score).short),
["Низкий", "Низкий", "Средний", "Средний", "Высокий", "Высокий", "Очень высокий", "Очень высокий"],
);
});
test("Russian plural forms cover common and exceptional endings", () => {
const forms = ["точка", "точки", "точек"] as const;
assert.deepEqual(
[0, 1, 2, 5, 11, 21, 22, 25].map(number => plural(number, forms)),
["точек", "точка", "точки", "точек", "точек", "точка", "точки", "точек"],
);
});
test("fish visual families follow body type instead of a name hash", () => {
assert.deepEqual(
["Щука", "Озёрная форель", "Карп", "Окунь", "Сом", "Угорь", "Палтус", "Треска", "Неизвестная рыба"].map(fishVisualFamily),
["pike", "salmonid", "cyprinid", "perch", "catfish", "eel", "flatfish", "marine", "generic"],
);
});
test("tackle glyphs only infer a type from explicit name terms", () => {
assert.deepEqual(
["Spiker #2", "Minnow 80F", "Salmon T1 Shad", "Клубничный бойл", "Червь", "Карповый монтаж", "Model 42", null].map(tackleVisualKind),
["spinner", "wobbler", "soft", "boilie", "worm", "rig", "unknown", "unknown"],
);
assert.equal(tackleVisualTone("Spiker #2"), tackleVisualTone("spiker #2"));
});