import { describe, it, expect } from "vitest";

import {
  validateEmail,
  validatePassword,
  validateUsername,
} from "@/app/auth/components/auth-validators";

describe("validateEmail", () => {
  it("accepts a valid email", () => {
    expect(validateEmail("user@example.com")).toBeNull();
  });
  it("rejects an empty email", () => {
    expect(validateEmail("")).not.toBeNull();
  });
  it("rejects an invalid email", () => {
    expect(validateEmail("not-an-email")).not.toBeNull();
  });
});

describe("validatePassword", () => {
  it("accepts a password >= 8 chars", () => {
    expect(validatePassword("12345678")).toBeNull();
  });
  it("rejects a too-short password", () => {
    expect(validatePassword("123")).not.toBeNull();
  });
});

describe("validateUsername", () => {
  it("accepts a 3+ char username", () => {
    expect(validateUsername("alice")).toBeNull();
  });
  it("rejects an empty username", () => {
    expect(validateUsername("")).not.toBeNull();
  });
  it("rejects a too-short username", () => {
    expect(validateUsername("ab")).not.toBeNull();
  });
});
