import { describe, expect, it } from "vitest"; import { normalizeEnemyAttack, type EnemyAttackDefinition } from "./enemyAttacks"; function attack(overrides: Partial): EnemyAttackDefinition { return { id: "test-special", name: "Test Special", delivery: "area", target: "nearby-party", school: "physical", animation: "attack", range: 12, cooldownMs: 10_000, damageMultiplier: 1, ...overrides, }; } describe("enemy attack telegraphs", () => { it("infers a warned cone for legacy frontal mechanics", () => { const normalized = normalizeEnemyAttack(attack({ name: "Stone Cleave" })); expect(normalized.telegraph).toMatchObject({ shape: "cone", anchor: "source", warningMs: 1_650, }); expect(normalized.castTimeMs).toBe(1_650); }); it("preserves authored geometry and extends too-short cast warnings", () => { const normalized = normalizeEnemyAttack(attack({ name: "Falling Ruin", castTimeMs: 500, telegraph: { shape: "circle", anchor: "target", warningMs: 2_200, radius: 7, }, })); expect(normalized.castTimeMs).toBe(2_200); expect(normalized.telegraph).toEqual({ shape: "circle", anchor: "target", warningMs: 2_200, radius: 7, }); }); it("does not telegraph basic attacks or beneficial mechanics", () => { expect(normalizeEnemyAttack(attack({ id: "basic-attack" })).telegraph).toBeUndefined(); expect(normalizeEnemyAttack(attack({ effect: { kind: "heal", multiplier: 1 }, })).telegraph).toBeUndefined(); }); });