import { describe, expect, it } from "vitest";
import { calculateQuote } from "@/domain/pricing";

describe("pricing", () => {
  it("calculates nightly rates, fees, taxes, discounts, and totals in minor units", () => {
    const quote = calculateQuote({
      range: { checkIn: "2026-08-01", checkOut: "2026-08-04" },
      currency: "EUR",
      baseNightlyMinor: 12000,
      overrides: {
        "2026-08-02": 15000,
      },
      fees: [{ code: "cleaning", label: "Cleaning", amountMinor: 3000 }],
      discounts: [{ code: "direct", label: "Direct booking", amountMinor: 2000 }],
      taxes: [{ code: "vat", label: "VAT", percentageBps: 2400 }],
      depositMinor: 10000,
    });

    expect(quote.nights).toBe(3);
    expect(quote.subtotalMinor).toBe(39000);
    expect(quote.taxes[0].amountMinor).toBe(9600);
    expect(quote.totalMinor).toBe(49600);
    expect(quote.nightlyPrices[1]).toEqual({
      date: "2026-08-02",
      amountMinor: 15000,
      source: "override",
    });
  });
});
