forked from phenom/healer-man
27 lines
1.6 KiB
TypeScript
27 lines
1.6 KiB
TypeScript
import { readFileSync, writeFileSync } from "node:fs";
|
|
import { describe, expect, it } from "vitest";
|
|
import { CLASSES } from "../app/characterCatalog";
|
|
import { DUNGEON_DEFINITIONS } from "./dungeonRegistry";
|
|
import { dungeonBossesForDifficulty, finalDungeonBoss } from "./dungeonRunStore";
|
|
|
|
describe("dungeon leaderboard catalog", () => {
|
|
it("keeps the server's final bosses, boss lists, difficulties, and classes aligned with the game", () => {
|
|
const catalog = {
|
|
dungeons: DUNGEON_DEFINITIONS.map((dungeon) => ({ id: dungeon.id, title: dungeon.title,
|
|
finalBossId: finalDungeonBoss(dungeon)?.id ?? "",
|
|
bosses: dungeon.bosses.map((boss) => ({ id: boss.id, name: boss.name })),
|
|
difficulties: dungeon.difficultyVariants.map((difficulty) => ({ id: difficulty.id, name: difficulty.difficulty,
|
|
bossIds: dungeonBossesForDifficulty(dungeon, difficulty.id).map((boss) => boss.id),
|
|
finalBossId: finalDungeonBoss(dungeon, difficulty.id)?.id ?? "" })),
|
|
defaultDifficultyId: dungeon.defaultDifficultyId,
|
|
})).sort((a, b) => a.id.localeCompare(b.id)),
|
|
classes: CLASSES.map((entry) => ({ id: entry.id, name: entry.name })),
|
|
};
|
|
expect(catalog.dungeons).toHaveLength(84);
|
|
expect(catalog.dungeons.filter((dungeon) => dungeon.bosses.length > 0 && !dungeon.finalBossId)).toEqual([]);
|
|
const path = "src/game/generated/dungeonLeaderboardCatalog.generated.json";
|
|
if (process.env.WRITE_DUNGEON_LEADERBOARD_CATALOG === "1") writeFileSync(path, `${JSON.stringify(catalog, null, 2)}\n`);
|
|
expect(JSON.parse(readFileSync(path, "utf8"))).toEqual(catalog);
|
|
});
|
|
});
|