import assert from "node:assert/strict"; import test from "node:test"; import { getRegistrationHubGate, getRegistrationHubDisplayState, getRegistrationHubGateCopy, getFinalPriceToman, normalizeCouponAmounts, } from "../src/lib/registration-hub-display.ts"; const now = Date.parse("2026-10-01T06:00:00.000Z"); test("closed and cancelled events use the registration-ended presentation", () => { const closedRegistration = getRegistrationHubGate({ status: "published", registration_end_date: "2026-09-30T00:00:00.000Z", }, now); const cancelledEvent = getRegistrationHubGate({ status: "cancelled" }, now); assert.equal(closedRegistration, "registration_ended"); assert.equal(cancelledEvent, "registration_ended"); assert.deepEqual(getRegistrationHubGateCopy(closedRegistration), { status: "پایان زمان ثبت‌نام", title: "پایان مهلت ثبت‌نام", subtitle: "", }); }); test("full events use the capacity-complete presentation", () => { const gate = getRegistrationHubGate({ status: "published", capacity: 5, registration_count: 5, }, now); assert.equal(gate, "capacity_full"); assert.deepEqual(getRegistrationHubGateCopy(gate), { status: "تکمیل ظرفیت", title: "ظرفیت رویداد تکمیل شده", subtitle: "", }); }); test("legacy unresolved checkout uses the unknown-payment presentation", () => { assert.equal(getRegistrationHubDisplayState("legacy_pending"), "verification_pending"); assert.equal(getRegistrationHubDisplayState("paid_success"), "paid_success"); }); test("coupon API amounts are converted from rial to toman for display", () => { assert.deepEqual(normalizeCouponAmounts({ discount_amount: 100_000, final_price: 1_150_000 }), { discount_amount: 10_000, final_price: 115_000, }); }); test("final event price is converted from rial to toman when no coupon is applied", () => { assert.equal(getFinalPriceToman(1_250_000), 125_000); });