Files
overleaf-cep/services/web/test/frontend/features/subscription/util/payment-dates.test.ts
T
Antoine Clausse ba4f024f34 [web] Remove SubscriptionFormatters, format subscription dates in the frontend (#36409)
* [web] Remove SubscriptionFormatters, format subscription dates in the frontend

Replace the server-formatted nextPaymentDueAt/nextPaymentDueDate/
trialEndsAtFormatted fields with the raw periodEnd date and format in
the React dashboard (same strings as before, English + UTC). Also
consolidate hand-rolled trial checks onto isInFreeTrial /
SubscriptionHelper.isInTrial.

* [web] Remove the now-unused dateformat dependency

* [web] Address review: payment-dates unit test, UTC dates in acceptance test

Add a dedicated unit test asserting the exact formatted strings from
formatPaymentDate/formatPaymentDateTime, and use explicit UTC timestamps
in the SubscriptionDashboard acceptance fixtures instead of
local-timezone Date constructors.

GitOrigin-RevId: 16ac4f1098b14ef9f1478d22cf39c1357ead7dea
2026-09-17 11:52:44 +00:00

32 lines
999 B
TypeScript

import { expect } from 'chai'
import {
formatPaymentDate,
formatPaymentDateTime,
} from '../../../../../frontend/js/features/subscription/util/payment-dates'
describe('payment-dates', function () {
describe('formatPaymentDate', function () {
it('formats a date in UTC', function () {
expect(formatPaymentDate('2025-02-20T12:00:00.000Z')).to.equal(
'February 20th, 2025'
)
})
it('returns null for missing dates', function () {
expect(formatPaymentDate(null)).to.be.null
expect(formatPaymentDate(undefined)).to.be.null
})
})
describe('formatPaymentDateTime', function () {
it('formats a date and time in UTC', function () {
expect(formatPaymentDateTime('2025-02-20T12:00:00.000Z')).to.equal(
'February 20th, 2025 12:00 PM UTC'
)
})
it('returns null for missing dates', function () {
expect(formatPaymentDateTime(null)).to.be.null
expect(formatPaymentDateTime(undefined)).to.be.null
})
})
})