import { expect } from "@esm-bundle/chai"; import sinon from "sinon"; import { GameLoop } from "../../../src/core/GameLoop.js"; import { createGameLoopSetup, cleanupGameLoop, } from "./helpers.js"; describe("Core: GameLoop - Stop", function () { this.timeout(30000); let gameLoop; let container; beforeEach(() => { const setup = createGameLoopSetup(); gameLoop = setup.gameLoop; container = setup.container; gameLoop.init(container); }); afterEach(() => { cleanupGameLoop(gameLoop, container); }); it("CoA 4: stop() should halt animation loop", (done) => { gameLoop.isRunning = true; // Spy on animate const spy = sinon.spy(gameLoop, "animate"); gameLoop.stop(); // Wait a short duration to ensure loop doesn't fire // Using setTimeout instead of requestAnimationFrame for reliability in headless env setTimeout(() => { expect(gameLoop.isRunning).to.be.false; done(); }, 50); }); });