import { describe, expect, it } from "vitest";
import {
  AuthenticationError,
  UnauthenticatedError,
  UnauthorizedError,
} from "./auth";
import { InputParseError } from "./common";

describe("AuthenticationError", () => {
  it("is an instance of Error with the given message", () => {
    const err = new AuthenticationError("bad credentials");
    expect(err).toBeInstanceOf(Error);
    expect(err.message).toBe("bad credentials");
  });
});

describe("UnauthenticatedError", () => {
  it("is an instance of Error with the given message", () => {
    const err = new UnauthenticatedError("not logged in");
    expect(err).toBeInstanceOf(Error);
    expect(err.message).toBe("not logged in");
  });
});

describe("UnauthorizedError", () => {
  it("is an instance of Error with the given message", () => {
    const err = new UnauthorizedError("forbidden");
    expect(err).toBeInstanceOf(Error);
    expect(err.message).toBe("forbidden");
  });
});

describe("InputParseError", () => {
  it("is an instance of Error with the given message", () => {
    const err = new InputParseError("invalid input");
    expect(err).toBeInstanceOf(Error);
    expect(err.message).toBe("invalid input");
  });
});
