import { describe, expect, it } from "vitest";
import { isAdmin } from "./is-admin";

describe("isAdmin", () => {
  it("returns true when user role is 'admin'", () => {
    expect(isAdmin({ req: { user: { role: "admin" } } })).toBe(true);
  });

  it("returns false when user role is not 'admin'", () => {
    expect(isAdmin({ req: { user: { role: "editor" } } })).toBe(false);
  });

  it("returns false when user has no role", () => {
    expect(isAdmin({ req: { user: {} } })).toBe(false);
  });

  it("returns false when there is no user", () => {
    expect(isAdmin({ req: {} })).toBe(false);
  });
});
