import { describe, expect, it } from "vitest";
import {
  assertBookingTransition,
  canTransitionBooking,
} from "@/domain/booking-states";

describe("booking states", () => {
  it("allows valid transitions", () => {
    expect(canTransitionBooking("held", "pending")).toBe(true);
    expect(canTransitionBooking("confirmed", "completed")).toBe(true);
  });

  it("rejects invalid transitions", () => {
    expect(canTransitionBooking("cancelled", "confirmed")).toBe(false);
    expect(() => assertBookingTransition("completed", "pending")).toThrow(
      "Invalid booking transition"
    );
  });
});
