Files
healer-man/src/game/wow335DruidMasterShapeshifterRuntime.test.ts
2026-10-02 10:38:12 -04:00

63 lines
3.5 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { applyTalentModifierValue, talentModifiersForRanks } from "./talentModifiers";
import {
WOW335_DRUID_MASTER_SHAPESHIFTER_TALENT_ID,
wow335DruidMasterShapeshifterModifiersForForm,
wow335DruidShapeshiftFormForAuraId,
wow335DruidShapeshiftFormForSpellId,
} from "./wow335DruidMasterShapeshifterRuntime";
describe("WoW Druid Master Shapeshifter runtime", () => {
it.each([
[1, 2],
[2, 4],
] as const)("uses the generated rank %i bonus only for its active form", (rank, expectedPercent) => {
const byForm = {
bear: wow335DruidMasterShapeshifterModifiersForForm(rank, "bear"),
cat: wow335DruidMasterShapeshifterModifiersForForm(rank, "cat"),
moonkin: wow335DruidMasterShapeshifterModifiersForForm(rank, "moonkin"),
tree: wow335DruidMasterShapeshifterModifiersForForm(rank, "tree-of-life"),
};
expect(byForm.bear).toHaveLength(1);
expect(byForm.bear[0]).toMatchObject({ kind: "damage-percent", amount: expectedPercent, scope: "physical damage" });
expect(byForm.cat).toHaveLength(1);
expect(byForm.cat[0]).toMatchObject({ kind: "critical-chance-percent", amount: expectedPercent, scope: "melee critical strike chance" });
expect(byForm.moonkin).toHaveLength(1);
expect(byForm.moonkin[0]).toMatchObject({ kind: "damage-percent", amount: expectedPercent, scope: "Arcane and Nature damage" });
expect(byForm.tree).toHaveLength(1);
expect(byForm.tree[0]).toMatchObject({ kind: "healing-percent", amount: expectedPercent, scope: "healing" });
expect(wow335DruidMasterShapeshifterModifiersForForm(rank, null)).toEqual([]);
expect(talentModifiersForRanks({ [WOW335_DRUID_MASTER_SHAPESHIFTER_TALENT_ID]: rank }, "druid"))
.toEqual([]);
});
it("maps only the supported WoW Druid forms to their talent clauses", () => {
expect(wow335DruidShapeshiftFormForSpellId(5487)).toBe("bear");
expect(wow335DruidShapeshiftFormForSpellId(9634)).toBe("bear");
expect(wow335DruidShapeshiftFormForSpellId(768)).toBe("cat");
expect(wow335DruidShapeshiftFormForSpellId(24858)).toBe("moonkin");
expect(wow335DruidShapeshiftFormForSpellId(33891)).toBe("tree-of-life");
expect(wow335DruidShapeshiftFormForSpellId(65139)).toBe("tree-of-life");
expect(wow335DruidShapeshiftFormForSpellId(783)).toBeNull();
expect(wow335DruidShapeshiftFormForAuraId("wow335:9634:bear-form")).toBe("bear");
expect(wow335DruidShapeshiftFormForAuraId("wow335:24858:moonkin-form")).toBe("moonkin");
expect(wow335DruidShapeshiftFormForAuraId("custom:783:travel-form")).toBeNull();
});
it("applies each modifier through the shared scalar matcher only after form selection", () => {
const bear = wow335DruidMasterShapeshifterModifiersForForm(2, "bear");
const cat = wow335DruidMasterShapeshifterModifiersForForm(2, "cat");
const moonkin = wow335DruidMasterShapeshifterModifiersForForm(2, "moonkin");
const tree = wow335DruidMasterShapeshifterModifiersForForm(2, "tree-of-life");
expect(applyTalentModifierValue(100, bear, "damage-percent", { abilityName: "Swipe (Bear)" })).toBe(104);
expect(applyTalentModifierValue(100, cat, "critical-chance-percent", { abilityName: "Claw" })).toBe(104);
expect(applyTalentModifierValue(100, moonkin, "damage-percent", { tags: ["nature"] })).toBe(104);
expect(applyTalentModifierValue(100, moonkin, "damage-percent", { tags: ["fire"] })).toBe(100);
expect(applyTalentModifierValue(100, tree, "healing-percent", { abilityName: "Rejuvenation" })).toBe(104);
});
});