programming-game
Version:
The client for programming game, an mmorpg that you interact with entirely through code.
31 lines (29 loc) • 861 B
text/typescript
import { describe, expect, it } from "vitest";
import { items } from "../src/items";
describe("items", () => {
describe("item id sanity check", () => {
it("should match keys to item ids", () => {
Object.keys(items).forEach((key) => {
expect(items[key as keyof typeof items].id).toBe(key);
});
});
});
describe("item names", () => {
it.each(Object.values(items).map((i) => i.name))(
"%s should be PascalCase",
(name) => {
const parts = name.split(" ");
const whitelist = new Set(["of", "and"]);
parts.forEach((part) => {
if (whitelist.has(part)) {
expect(part).toBe(part.toLowerCase());
} else {
expect(part).toMatch(
part.slice(0, 1).toUpperCase() + part.slice(1)
);
}
});
}
);
});
});