import { describe, it, expect } from "vitest";
import { formatCurrency, formatCompact } from "./format";

describe("INR formatting", () => {
  it("shows the rupee sign with no decimals for large amounts", () => {
    expect(formatCurrency(80000, "INR")).toBe("₹80,000");
    expect(formatCurrency(1234567, "INR")).toBe("₹1,234,567");
  });

  it("shows paise only for small amounts, and never when suppressed", () => {
    expect(formatCurrency(499, "INR")).toBe("₹499.00");
    expect(formatCurrency(643, "INR", 0)).toBe("₹643");
  });

  it("keeps USD formatting intact", () => {
    expect(formatCurrency(80000, "USD")).toBe("$80,000");
    expect(formatCurrency(643, "USD", 0)).toBe("$643");
  });

  it("compacts INR with the rupee sign", () => {
    expect(formatCompact(50000, "INR")).toContain("₹");
  });

  it("falls back to dollars when the currency is invalid", () => {
    expect(formatCurrency(100, "nope")).toBe("$100.00");
  });
});
