forked from phenom/healer-man
107 lines
3.6 KiB
TypeScript
107 lines
3.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { ActiveAura, AuraDefinition } from "../game/combatAuras";
|
|
import {
|
|
LONG_TERM_AURA_DURATION_MS,
|
|
auraDisplayName,
|
|
auraDefinitionDisplaysInStrip,
|
|
auraDefinitionIcon,
|
|
auraDefinitionIsDispellableDebuff,
|
|
auraDefinitionIsLongTerm,
|
|
auraDescription,
|
|
groupAurasForDisplay,
|
|
} from "./auraDisplay";
|
|
|
|
function aura(overrides: Partial<AuraDefinition> = {}): AuraDefinition {
|
|
return {
|
|
id: "test-aura",
|
|
name: "Test Aura",
|
|
disposition: "debuff",
|
|
durationMs: 10_000,
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
function activeAura(definition: AuraDefinition, remainingAbsorb = 0): ActiveAura {
|
|
return {
|
|
instanceId: "test-aura-instance",
|
|
definition,
|
|
sourceId: "source",
|
|
targetId: "target",
|
|
appliedAt: 1_000,
|
|
expiresAt: definition.durationMs === null ? null : 1_000 + definition.durationMs,
|
|
stacks: 1,
|
|
absorbs: remainingAbsorb > 0
|
|
? [{ id: "test-absorb", remaining: remainingAbsorb }]
|
|
: [],
|
|
procStates: [],
|
|
};
|
|
}
|
|
|
|
describe("aura strip visibility", () => {
|
|
it("shows ordinary auras and suppresses periodic shadow auras with dedicated timers", () => {
|
|
expect(auraDefinitionDisplaysInStrip(aura())).toBe(true);
|
|
expect(auraDefinitionDisplaysInStrip(aura({ hideFromAuraStrip: true }))).toBe(false);
|
|
});
|
|
|
|
it("uses spell artwork while retaining the initial fallback for iconless effects", () => {
|
|
expect(auraDefinitionIcon(aura({ icon: " /assets/ui/spells/test.png " }))).toBe(
|
|
"/assets/ui/spells/test.png",
|
|
);
|
|
expect(auraDefinitionIcon(aura())).toBeNull();
|
|
});
|
|
|
|
it("removes internal DBC and aura identifiers from player-facing names", () => {
|
|
expect(auraDisplayName(aura({ name: "Power Word: Fortitude (DBC 1243, Aura 29)" }))).toBe(
|
|
"Power Word: Fortitude",
|
|
);
|
|
expect(auraDisplayName(aura({ name: "Arcane Intellect (Aura 13)" }))).toBe(
|
|
"Arcane Intellect",
|
|
);
|
|
});
|
|
|
|
it("classifies permanent and one-minute effects as long-term without using remaining time", () => {
|
|
expect(auraDefinitionIsLongTerm(aura({ durationMs: null }))).toBe(true);
|
|
expect(auraDefinitionIsLongTerm(aura({ durationMs: LONG_TERM_AURA_DURATION_MS }))).toBe(true);
|
|
expect(auraDefinitionIsLongTerm(aura({ durationMs: LONG_TERM_AURA_DURATION_MS - 1 }))).toBe(false);
|
|
});
|
|
|
|
it("identifies only categorized debuffs as dispellable player effects", () => {
|
|
expect(auraDefinitionIsDispellableDebuff(aura({ dispelCategory: "magic" }))).toBe(true);
|
|
expect(auraDefinitionIsDispellableDebuff(aura())).toBe(false);
|
|
expect(auraDefinitionIsDispellableDebuff(aura({
|
|
disposition: "buff",
|
|
dispelCategory: "magic",
|
|
}))).toBe(false);
|
|
});
|
|
|
|
it("prefers authored tooltip copy and explains absorb-only fallback auras", () => {
|
|
expect(auraDescription(activeAura(aura({ description: "Raises armor by 10%." })))).toBe(
|
|
"Raises armor by 10%.",
|
|
);
|
|
expect(auraDescription(activeAura(aura({
|
|
absorbs: [{ id: "test-absorb", amount: 250 }],
|
|
}), 175))).toBe("Absorbs up to 175 incoming damage.");
|
|
});
|
|
|
|
it("shows multi-effect and repeatedly sourced spell auras as one icon", () => {
|
|
const first = activeAura(aura({
|
|
id: "frostbolt-slow",
|
|
name: "Frostbolt (DBC 116, Aura 33)",
|
|
icon: "/assets/ui/spells/frostbolt.png",
|
|
}));
|
|
const second = {
|
|
...activeAura(aura({
|
|
id: "frostbolt-secondary",
|
|
name: "Frostbolt (DBC 116, Aura 118)",
|
|
icon: "/assets/ui/spells/frostbolt.png",
|
|
})),
|
|
instanceId: "second-frostbolt-aura",
|
|
sourceId: "second-mage",
|
|
appliedAt: 2_000,
|
|
expiresAt: 14_000,
|
|
};
|
|
|
|
expect(groupAurasForDisplay([first, second])).toEqual([second]);
|
|
});
|
|
});
|