Address NameLayer review feedback

This commit is contained in:
scamiv
2026-05-27 14:36:16 +02:00
parent fe216cba4b
commit 645efeab9d
7 changed files with 225 additions and 70 deletions
+29
View File
@@ -101,9 +101,28 @@ describe("NameLayerLayout", () => {
expect(computeTraitorFlashDurationSeconds(150)).toBeCloseTo(1);
expect(computeTraitorFlashDurationSeconds(0)).toBeCloseTo(0.2);
expect(computeTraitorFlashAlpha(150, 0)).toBeCloseTo(1);
expect(computeTraitorFlashAlpha(150, 250)).toBeCloseTo(0.65);
expect(computeTraitorFlashAlpha(150, 500)).toBeCloseTo(0.3);
});
test("spreads multiple centered icons instead of stacking them", () => {
const layout = computeNameLayerLayout({
fontSize: 10,
iconSize: 15,
iconCount: 0,
centeredIconCount: 2,
hasFlag: false,
flagAspectRatio: 1,
nameWidth: 40,
troopWidth: 30,
});
expect(layout.centeredIconPositions).toEqual([
{ x: -9.5, y: -4.75 },
{ x: 9.5, y: -4.75 },
]);
});
test("replaces unsupported glyphs once per glyph", () => {
resetNameLayerGlyphWarningsForTests();
const warn = vi.fn();
@@ -112,4 +131,14 @@ describe("NameLayerLayout", () => {
expect(replaceUnsupportedNameGlyphs("🙂", warn)).toBe("?");
expect(warn).toHaveBeenCalledTimes(1);
});
test("replaces unsupported grapheme clusters with one fallback glyph", () => {
resetNameLayerGlyphWarningsForTests();
const warn = vi.fn();
expect(
replaceUnsupportedNameGlyphs("A\u{1F469}\u200D\u{1F4BB}B", warn),
).toBe("A?B");
expect(warn).toHaveBeenCalledTimes(1);
});
});