import { describe, it, expect } from "vitest";
import {
  welcomeEmail,
  alertNotificationEmail,
  passwordResetEmail,
  familyInviteEmail,
  billingReceiptEmail,
} from "./email.templates";

describe("welcomeEmail", () => {
  it("includes the user name in the output", () => {
    const result = welcomeEmail("Alice");
    expect(result.subject).toContain("Welcome");
    expect(result.html).toContain("Alice");
    expect(result.text).toContain("Alice");
    expect(result.html).toContain("ShieldAI");
  });
});

describe("alertNotificationEmail", () => {
  it("includes severity and alert details", () => {
    const result = alertNotificationEmail("Data Breach Found", "Your email was exposed", "critical");
    expect(result.subject).toContain("CRITICAL");
    expect(result.html).toContain("Data Breach Found");
    expect(result.html).toContain("Your email was exposed");
    expect(result.text).toContain("CRITICAL");
  });

  it("renders different severity levels", () => {
    const infoResult = alertNotificationEmail("Scan Complete", "Scan done", "info");
    expect(infoResult.subject).toContain("INFO");

    const warnResult = alertNotificationEmail("Suspicious Activity", "Suspicious login", "warning");
    expect(warnResult.subject).toContain("WARNING");
  });
});

describe("passwordResetEmail", () => {
  it("includes the reset link", () => {
    const result = passwordResetEmail("https://shieldai.app/reset/token123");
    expect(result.html).toContain("https://shieldai.app/reset/token123");
    expect(result.text).toContain("https://shieldai.app/reset/token123");
    expect(result.subject).toContain("Reset");
  });
});

describe("familyInviteEmail", () => {
  it("includes inviter name and group name", () => {
    const result = familyInviteEmail("Bob", "Smith Family", "https://shieldai.app/invite/abc");
    expect(result.html).toContain("Bob");
    expect(result.html).toContain("Smith Family");
    expect(result.html).toContain("https://shieldai.app/invite/abc");
    expect(result.subject).toContain("Bob");
  });
});

describe("billingReceiptEmail", () => {
  it("includes payment details", () => {
    const result = billingReceiptEmail("Premium Plan", "$19.99", "Mar 15, 2025", "https://shieldai.app/receipt/r1");
    expect(result.html).toContain("Premium Plan");
    expect(result.html).toContain("$19.99");
    expect(result.html).toContain("Mar 15, 2025");
    expect(result.html).toContain("https://shieldai.app/receipt/r1");
    expect(result.subject).toContain("Premium Plan");
  });
});
