import { describe, it, expect } from "vitest";
import { HIBPService } from "../src/hibp/HIBPService";
import { Severity } from "@shieldai/types";

describe("HIBPService", () => {
  const hibp = new HIBPService();

  it("computes severity for critical data classes", () => {
    const breach = {
      name: "TestBreach",
      title: "Test Breach",
      domain: "test.com",
      loginCount: 0,
      passwordCount: 0,
      date: new Date(),
      breachDate: new Date(),
      addedDate: new Date(),
      pwnCount: 1000,
      dataClasses: ["Password", "Email Address"],
      logo: "",
    };
    expect(hibp.getSeverity(breach)).toBe(Severity.CRITICAL);
  });

  it("computes severity for warning data classes", () => {
    const breach = {
      name: "TestBreach",
      title: "Test Breach",
      domain: "test.com",
      loginCount: 0,
      passwordCount: 0,
      date: new Date(),
      breachDate: new Date(),
      addedDate: new Date(),
      pwnCount: 1000,
      dataClasses: ["Phone Number"],
      logo: "",
    };
    expect(hibp.getSeverity(breach)).toBe(Severity.WARNING);
  });

  it("computes INFO for old non-critical breaches", () => {
    const breach = {
      name: "OldBreach",
      title: "Old Breach",
      domain: "old.com",
      loginCount: 0,
      passwordCount: 0,
      date: new Date(),
      breachDate: new Date(Date.now() - 400 * 24 * 60 * 60 * 1000),
      addedDate: new Date(),
      pwnCount: 1000,
      dataClasses: ["Name"],
      logo: "",
    };
    expect(hibp.getSeverity(breach)).toBe(Severity.INFO);
  });

  it("maps to HIBP data source", () => {
    expect(hibp.mapToDataSource()).toBe("HIBP");
  });
});
