22 lines
843 B
TypeScript
22 lines
843 B
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import { createFlowOverlayState, stopFlowAnimation } from "./flow-overlay";
|
|
|
|
describe("flow overlay lifecycle", () => {
|
|
it("starts empty so conduit data can be loaded once per map session", () => {
|
|
expect(createFlowOverlayState()).toEqual({ data: null, animationFrameId: null, overlay: null });
|
|
});
|
|
|
|
it("cancels an active animation frame without clearing cached data", () => {
|
|
const cancelAnimationFrame = vi.fn();
|
|
vi.stubGlobal("window", { cancelAnimationFrame });
|
|
const state = createFlowOverlayState();
|
|
state.data = [];
|
|
state.animationFrameId = 42;
|
|
stopFlowAnimation(state);
|
|
expect(cancelAnimationFrame).toHaveBeenCalledWith(42);
|
|
expect(state.animationFrameId).toBeNull();
|
|
expect(state.data).toBeTruthy();
|
|
vi.unstubAllGlobals();
|
|
});
|
|
});
|