fix: add JSDoc header and null input test for rarity config

This commit is contained in:
syntaxbullet
2026-03-18 21:49:10 +01:00
parent b8303a7e28
commit 0517cd638c
2 changed files with 10 additions and 0 deletions

View File

@@ -18,6 +18,11 @@ describe("getRarityConfig", () => {
const result = getRarityConfig("LEGENDARY");
expect(result).toEqual(RARITY_CONFIG["C"]);
});
it("falls back to Common for null/undefined input", () => {
expect(getRarityConfig(null as any)).toEqual(RARITY_CONFIG["C"]);
expect(getRarityConfig(undefined as any)).toEqual(RARITY_CONFIG["C"]);
});
});
describe("defaultName", () => {

View File

@@ -1,3 +1,8 @@
/**
* Shared Rarity Configuration
* Provides the canonical rarity display config (colors, emoji, labels)
* used by lootbox pull results and shop loot table views.
*/
export const RARITY_CONFIG: Record<string, { color: number; emoji: string; label: string }> = {
C: { color: 0x95A5A6, emoji: "📦", label: "Common" },
R: { color: 0x3498DB, emoji: "📦", label: "Rare" },