refactor: Abbreviate item rarity values from full names to single-letter codes across the application.

This commit is contained in:
syntaxbullet
2026-02-06 13:00:41 +01:00
parent db4e7313c3
commit 1929f0dd1f
10 changed files with 37 additions and 43 deletions

View File

@@ -28,7 +28,7 @@ let mockItems: MockItem[] = [
id: 1,
name: "Health Potion",
description: "Restores health",
rarity: "Common",
rarity: "C",
type: "CONSUMABLE",
price: 100n,
iconUrl: "/assets/items/1.png",
@@ -39,7 +39,7 @@ let mockItems: MockItem[] = [
id: 2,
name: "Iron Sword",
description: "A basic sword",
rarity: "Uncommon",
rarity: "R",
type: "EQUIPMENT",
price: 500n,
iconUrl: "/assets/items/2.png",
@@ -96,7 +96,7 @@ mock.module("@shared/modules/items/items.service", () => ({
id: mockIdCounter++,
name: data.name,
description: data.description ?? null,
rarity: data.rarity ?? "Common",
rarity: data.rarity ?? "C",
type: data.type,
price: data.price ?? null,
iconUrl: data.iconUrl,
@@ -154,7 +154,7 @@ describe("Items API", () => {
id: 1,
name: "Health Potion",
description: "Restores health",
rarity: "Common",
rarity: "C",
type: "CONSUMABLE",
price: 100n,
iconUrl: "/assets/items/1.png",
@@ -165,7 +165,7 @@ describe("Items API", () => {
id: 2,
name: "Iron Sword",
description: "A basic sword",
rarity: "Uncommon",
rarity: "R",
type: "EQUIPMENT",
price: 500n,
iconUrl: "/assets/items/2.png",
@@ -217,11 +217,11 @@ describe("Items API", () => {
});
test("should filter items by rarity", async () => {
const response = await fetch(`${baseUrl}/api/items?rarity=Common`);
const response = await fetch(`${baseUrl}/api/items?rarity=C`);
expect(response.status).toBe(200);
const data = (await response.json()) as { items: MockItem[]; total: number };
expect(data.items.every((item) => item.rarity === "Common")).toBe(true);
expect(data.items.every((item) => item.rarity === "C")).toBe(true);
});
});
@@ -255,7 +255,7 @@ describe("Items API", () => {
const newItem = {
name: "Magic Staff",
description: "A powerful staff",
rarity: "Rare",
rarity: "SR",
type: "EQUIPMENT",
price: "1000",
iconUrl: "/assets/items/placeholder.png",