// Wiring test for the username plugin: the Drizzle schema must carry the
// plugin's columns, and the auth instance must expose its server endpoints.
import { describe, expect, test } from "bun:test";
import { auth } from "../auth";
import { user } from "../db/auth-schema";

describe("username plugin wiring", () => {
  test("user table carries the plugin's columns", () => {
    expect(user.username).toBeDefined();
    expect(user.username.name).toBe("username");
    expect(user.username.isUnique).toBe(true);
    expect(user.displayUsername).toBeDefined();
    expect(user.displayUsername.name).toBe("display_username");
  });

  test("auth.api exposes the username endpoints", () => {
    // /sign-in/username + /is-username-available (endpoint ids in
    // node_modules/better-auth/dist/plugins/username/index.d.mts).
    expect(typeof auth.api.signInUsername).toBe("function");
    expect(typeof auth.api.isUsernameAvailable).toBe("function");
  });
});
