import { describe, it, expectTypeOf } from "vitest";
import type { Instrumented, Captured } from "@/conformance/brands";

describe("brand types", () => {
  it("Instrumented<F> is structurally F plus a phantom flag", () => {
    type Fn = (n: number) => Promise<string>;
    expectTypeOf<Instrumented<Fn>>().toBeCallableWith(1);
    expectTypeOf<Instrumented<Fn>>().returns.resolves.toEqualTypeOf<string>();
    // The flag is readonly and required for assignability checks.
    expectTypeOf<Instrumented<Fn>["__instrumented"]>().toEqualTypeOf<true>();
  });

  it("Captured<F> is structurally F plus a phantom flag", () => {
    type Fn = (n: number) => Promise<string>;
    expectTypeOf<Captured<Fn>>().toBeCallableWith(1);
    expectTypeOf<Captured<Fn>["__captured"]>().toEqualTypeOf<true>();
  });

  it("brands compose without conflict", () => {
    type Fn = (n: number) => Promise<string>;
    type Both = Instrumented<Fn> & Captured<Fn>;
    expectTypeOf<Both>().toBeCallableWith(1);
    expectTypeOf<Both["__instrumented"]>().toEqualTypeOf<true>();
    expectTypeOf<Both["__captured"]>().toEqualTypeOf<true>();
  });
});
