Files
aurorabot/shared/lib/rarity.test.ts
syntaxbullet 5188d86d61
Some checks failed
Deploy to Production / test (push) Failing after 31s
fix(inventory): address code review findings
- Replace setTimeout race in use-item flow with explicit Back button
- Fix collector end handler to re-render current view instead of blanking
- Add appendUseBackButton helper to attach navigation to use results
- Remove unused isInventoryInteraction import
- Fix rarity test type assertions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 17:49:12 +01:00

37 lines
1.2 KiB
TypeScript

import { describe, it, expect } from "bun:test";
import { getRarityConfig, RARITY_CONFIG, defaultName } from "./rarity";
describe("getRarityConfig", () => {
it("returns correct config for known rarities", () => {
expect(getRarityConfig("SSR").color).toBe(0xF1C40F);
expect(getRarityConfig("SSR").emoji).toBe("🌟");
expect(getRarityConfig("SSR").label).toBe("SSR");
});
it("returns correct config for loot types", () => {
expect(getRarityConfig("CURRENCY").color).toBe(0x2ECC71);
expect(getRarityConfig("XP").color).toBe(0x1ABC9C);
expect(getRarityConfig("NOTHING").color).toBe(0x636363);
});
it("falls back to Common for unknown rarity", () => {
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", () => {
it("extracts filename from path", () => {
expect(defaultName("/assets/items/sword.png")).toBe("sword.png");
});
it("returns image.png for empty path", () => {
expect(defaultName("")).toBe("image.png");
});
});