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

import { hashPassword, verifyPassword } from "./password";

describe("password", () => {
  it("hashes and verifies a password roundtrip", async () => {
    const plain = "super-secure-password-123!";
    const hashed = await hashPassword(plain);

    expect(hashed).not.toBe(plain);
    expect(await verifyPassword(plain, hashed)).toBe(true);
  });

  it("rejects an incorrect password", async () => {
    const hashed = await hashPassword("correct-password");

    expect(await verifyPassword("wrong-password", hashed)).toBe(false);
  });
});
