statewave
Version:
Another Finite State Machine
23 lines (18 loc) • 611 B
text/typescript
import { describe, expect, test } from "vitest";
import { machine, state, transition } from "..";
type TodosEvent = "load" | "select";
type TodosState = "loading" | "ready" | "error";
describe("machine", () => {
test("main test for todos machine", () => {
const fetchMachine = machine<TodosState, TodosEvent>(
{
loading: state(transition("load", "ready")),
ready: state(transition("select", "error")),
error: state(transition("select", "loading")),
},
{ initial: "loading" }
);
console.log(fetchMachine);
expect(1 + 1 === 2).toBe(true);
});
});