import { describe, expect, it } from "vitest"; import { WOW335_DEATH_KNIGHT_SUDDEN_DOOM_DEATH_COIL_ABILITY_ID, WOW335_DEATH_KNIGHT_SUDDEN_DOOM_TRIGGER_ABILITY_IDS, wow335DeathKnightSuddenDoomTriggerForLandedHit, wow335DeathKnightSuddenDoomProcChance, } from "./wow335DeathKnightSuddenDoomRuntime"; describe("WoW Death Knight Sudden Doom source runtime", () => { it("reads the generated 5/10/15% rank chances", () => { expect([0, 1, 2, 3].map(wow335DeathKnightSuddenDoomProcChance)).toEqual([0, 0.05, 0.1, 0.15]); }); it("returns a one-use free Death Coil instruction on an eligible landed hit at the generated chance", () => { for (const triggerAbilityId of WOW335_DEATH_KNIGHT_SUDDEN_DOOM_TRIGGER_ABILITY_IDS) { expect(wow335DeathKnightSuddenDoomTriggerForLandedHit(3, triggerAbilityId, "target-1", true, 0)) .toEqual({ abilityId: WOW335_DEATH_KNIGHT_SUDDEN_DOOM_DEATH_COIL_ABILITY_ID, targetId: "target-1", free: true, }); } expect(wow335DeathKnightSuddenDoomTriggerForLandedHit( 1, WOW335_DEATH_KNIGHT_SUDDEN_DOOM_TRIGGER_ABILITY_IDS[0], "target-1", true, 0.05, )).toBeNull(); expect(wow335DeathKnightSuddenDoomTriggerForLandedHit( 3, "wow335-death-knight-obliterate", "target-1", true, 0, )).toBeNull(); }); it("does not proc on misses, targetless events, absent ranks, or invalid rolls", () => { const bloodStrike = WOW335_DEATH_KNIGHT_SUDDEN_DOOM_TRIGGER_ABILITY_IDS[0]; expect(wow335DeathKnightSuddenDoomTriggerForLandedHit(3, bloodStrike, "target-1", false, 0)).toBeNull(); expect(wow335DeathKnightSuddenDoomTriggerForLandedHit(3, bloodStrike, null, true, 0)).toBeNull(); expect(wow335DeathKnightSuddenDoomTriggerForLandedHit(0, bloodStrike, "target-1", true, 0)).toBeNull(); expect(wow335DeathKnightSuddenDoomTriggerForLandedHit(3, bloodStrike, "target-1", true, -0.01)).toBeNull(); expect(wow335DeathKnightSuddenDoomTriggerForLandedHit(3, bloodStrike, "target-1", true, Number.NaN)).toBeNull(); }); });