import { describe, test, expect } from "bun:test";

/**
 * Tests for the HonoTypes and PermissionTypes type exports.
 * These are mainly compile-time checks that ensure the types exist
 * and can be used.
 */
import type { Variables } from "../../src/types/HonoTypes";
import type {
  PermissionIssuers,
  DecodedPermissionsBlock,
} from "../../src/types/PermissionTypes";

describe("HonoTypes", () => {
  test("Variables type is usable", () => {
    // If this compiles and runs, the type exists
    const vars: Variables = { user: {} as any };
    expect(vars).toBeDefined();
  });
});

describe("PermissionTypes", () => {
  test("PermissionIssuers type accepts valid values", () => {
    const issuers: PermissionIssuers[] = ["roles", "user", "api_key"];
    expect(issuers).toHaveLength(3);
  });

  test("DecodedPermissionsBlock shape is correct", () => {
    const block: DecodedPermissionsBlock = {
      permissions: ["admin.*"],
      iat: 1234567890,
      iss: "roles",
      sub: "role-1",
    };
    expect(block.permissions).toEqual(["admin.*"]);
    expect(block.iss).toBe("roles");
  });
});
