import { describe, expect, it } from "vitest";
import { isActorAnimationOneShot, shouldStartActorAnimation } from "./actorAnimation";

describe("actor animation playback", () => {
  it("restarts a repeated attack when a new combat action begins", () => {
    expect(shouldStartActorAnimation("attack", 4.2, "attack", 5.3)).toBe(true);
  });

  it("does not restart the same combat action every frame", () => {
    expect(shouldStartActorAnimation("attack", 4.2, "attack", 4.2)).toBe(false);
  });

  it("keeps looping locomotion stable while its trigger changes", () => {
    expect(shouldStartActorAnimation("walk", 0, "walk", 1)).toBe(false);
    expect(shouldStartActorAnimation("run", 0, "run", 1)).toBe(false);
  });

  it("starts when the actor changes animation state", () => {
    expect(shouldStartActorAnimation("attack", 4.2, "walk", 0)).toBe(true);
    expect(isActorAnimationOneShot("death")).toBe(true);
  });
});
