You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
812 B
25 lines
812 B
import { describe, expect, it } from "vitest";
|
|
import {
|
|
assertTransition,
|
|
canTransition,
|
|
IllegalTransition,
|
|
} from "@/services/state-machine";
|
|
|
|
describe("state-machine", () => {
|
|
it("allows FETCHED → PARSING", () => {
|
|
expect(canTransition("FETCHED", "PARSING")).toBe(true);
|
|
});
|
|
it("allows PARSING → PENDING_CONFIRM", () => {
|
|
expect(() => assertTransition("PARSING", "PENDING_CONFIRM")).not.toThrow();
|
|
});
|
|
it("rejects SUCCESS → PARSING", () => {
|
|
expect(() => assertTransition("SUCCESS", "PARSING")).toThrow(IllegalTransition);
|
|
});
|
|
it("allows PARSE_FAILED → PARSING", () => {
|
|
expect(canTransition("PARSE_FAILED", "PARSING")).toBe(true);
|
|
});
|
|
it("allows PARSING → FETCHED (stale reaper)", () => {
|
|
expect(canTransition("PARSING", "FETCHED")).toBe(true);
|
|
});
|
|
});
|