jsfsm/tests/stepEvent.test.js
rts-pyers 0123a2e9b4 init
2025-08-11 16:28:38 -04:00

20 lines
538 B
JavaScript

import { describe, it, expect, vi } from "vitest";
import { createMachine } from "../src/index";
describe("step event", () => {
it("should emit step event after ticks and transitions", () => {
const machine = createMachine({
data: {},
states: { x: 1, y: 0 },
transitions: [{ from: "x", to: "y", when: () => true }],
});
const stepSpy = vi.fn();
machine.on("step", stepSpy);
machine.step();
expect(stepSpy).toHaveBeenCalledWith({
state: ["y"],
data: machine.data,
});
});
});