--deny warnings was a no-op (not a valid category); the correct flag is --deny-warnings. Fixed all 8 pre-existing warnings and removed every biome-ignore from source and test files. Simplified the check script to zero-tolerance: any biome-ignore now fails the build. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
128 lines
4.1 KiB
TypeScript
128 lines
4.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
CONDITION_DEFINITIONS,
|
|
getConditionDescription,
|
|
getConditionsForEdition,
|
|
} from "../conditions.js";
|
|
|
|
function findCondition(id: string) {
|
|
const def = CONDITION_DEFINITIONS.find((d) => d.id === id);
|
|
if (!def) throw new Error(`Condition ${id} not found`);
|
|
return def;
|
|
}
|
|
|
|
describe("getConditionDescription", () => {
|
|
it("returns 5.5e description by default", () => {
|
|
const exhaustion = findCondition("exhaustion");
|
|
expect(getConditionDescription(exhaustion, "5.5e")).toBe(
|
|
exhaustion.description,
|
|
);
|
|
});
|
|
|
|
it("returns 5e description when edition is 5e", () => {
|
|
const exhaustion = findCondition("exhaustion");
|
|
expect(getConditionDescription(exhaustion, "5e")).toBe(
|
|
exhaustion.description5e,
|
|
);
|
|
});
|
|
|
|
it("returns pf2e description when edition is pf2e", () => {
|
|
const blinded = findCondition("blinded");
|
|
expect(getConditionDescription(blinded, "pf2e")).toBe(
|
|
blinded.descriptionPf2e,
|
|
);
|
|
});
|
|
|
|
it("falls back to default description for pf2e when no pf2e text", () => {
|
|
const paralyzed = findCondition("paralyzed");
|
|
expect(getConditionDescription(paralyzed, "pf2e")).toBe(
|
|
paralyzed.descriptionPf2e,
|
|
);
|
|
});
|
|
|
|
it("shared D&D conditions have both description and description5e", () => {
|
|
const sharedDndConditions = CONDITION_DEFINITIONS.filter(
|
|
(d) =>
|
|
d.systems === undefined ||
|
|
(d.systems.includes("5e") && d.systems.includes("5.5e")),
|
|
);
|
|
for (const def of sharedDndConditions) {
|
|
expect(def.description).toBeTruthy();
|
|
expect(def.description5e).toBeTruthy();
|
|
}
|
|
});
|
|
|
|
it("system-specific conditions use the systems field", () => {
|
|
const sapped = findCondition("sapped");
|
|
expect(sapped.description).toBeTruthy();
|
|
expect(sapped.systems).toContain("5.5e");
|
|
|
|
const slowed = findCondition("slowed");
|
|
expect(slowed.description).toBeTruthy();
|
|
expect(slowed.systems).toContain("5.5e");
|
|
});
|
|
|
|
it("conditions with identical rules share the same text", () => {
|
|
const blinded = findCondition("blinded");
|
|
expect(blinded.description).toBe(blinded.description5e);
|
|
});
|
|
|
|
it("conditions with different rules have different text", () => {
|
|
const exhaustion = findCondition("exhaustion");
|
|
expect(exhaustion.description).not.toBe(exhaustion.description5e);
|
|
});
|
|
});
|
|
|
|
describe("getConditionsForEdition", () => {
|
|
it("includes sapped and slowed for 5.5e", () => {
|
|
const conditions = getConditionsForEdition("5.5e");
|
|
const ids = conditions.map((d) => d.id);
|
|
expect(ids).toContain("sapped");
|
|
expect(ids).toContain("slowed");
|
|
});
|
|
|
|
it("excludes sapped and slowed for 5e", () => {
|
|
const conditions = getConditionsForEdition("5e");
|
|
const ids = conditions.map((d) => d.id);
|
|
expect(ids).not.toContain("sapped");
|
|
expect(ids).not.toContain("slowed");
|
|
});
|
|
|
|
it("includes universal conditions for both editions", () => {
|
|
const ids5e = getConditionsForEdition("5e").map((d) => d.id);
|
|
const ids55e = getConditionsForEdition("5.5e").map((d) => d.id);
|
|
expect(ids5e).toContain("blinded");
|
|
expect(ids55e).toContain("blinded");
|
|
});
|
|
|
|
it("returns PF2e conditions for pf2e edition", () => {
|
|
const conditions = getConditionsForEdition("pf2e");
|
|
const ids = conditions.map((d) => d.id);
|
|
expect(ids).toContain("clumsy");
|
|
expect(ids).toContain("drained");
|
|
expect(ids).toContain("off-guard");
|
|
expect(ids).toContain("sickened");
|
|
expect(ids).not.toContain("charmed");
|
|
expect(ids).not.toContain("exhaustion");
|
|
expect(ids).not.toContain("grappled");
|
|
});
|
|
|
|
it("returns D&D conditions for 5.5e", () => {
|
|
const conditions = getConditionsForEdition("5.5e");
|
|
const ids = conditions.map((d) => d.id);
|
|
expect(ids).toContain("charmed");
|
|
expect(ids).toContain("exhaustion");
|
|
expect(ids).not.toContain("clumsy");
|
|
expect(ids).not.toContain("off-guard");
|
|
});
|
|
|
|
it("shared conditions appear in both D&D and PF2e", () => {
|
|
const dndIds = getConditionsForEdition("5.5e").map((d) => d.id);
|
|
const pf2eIds = getConditionsForEdition("pf2e").map((d) => d.id);
|
|
expect(dndIds).toContain("blinded");
|
|
expect(pf2eIds).toContain("blinded");
|
|
expect(dndIds).toContain("prone");
|
|
expect(pf2eIds).toContain("prone");
|
|
});
|
|
});
|