import { describe, it, expect } from "vitest";
import { isCheckinHost, isPathAllowedOnCheckinHost } from "../host";

describe("isCheckinHost", () => {
  it("matches the checkin subdomain, ignoring port + case", () => {
    expect(isCheckinHost("checkin.alqove.com")).toBe(true);
    expect(isCheckinHost("Checkin.Alqove.com:443")).toBe(true);
  });
  it("rejects the main app host and empty host", () => {
    expect(isCheckinHost("alqove.com")).toBe(false);
    expect(isCheckinHost("localhost:3000")).toBe(false);
    expect(isCheckinHost(null)).toBe(false);
  });
});

describe("isPathAllowedOnCheckinHost", () => {
  it("allows only the public lane paths", () => {
    expect(isPathAllowedOnCheckinHost("/c/tok123")).toBe(true);
    expect(isPathAllowedOnCheckinHost("/c/tok123/s/st1")).toBe(true);
    expect(isPathAllowedOnCheckinHost("/c")).toBe(true);
  });
  it("blocks main-app paths", () => {
    expect(isPathAllowedOnCheckinHost("/")).toBe(false);
    expect(isPathAllowedOnCheckinHost("/items")).toBe(false);
    expect(isPathAllowedOnCheckinHost("/cart")).toBe(false);
  });
});
