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

This reverts commit 2939e71e5b919529cbb8a602916d5f597d117792.

* Fixup after rename conflict: `nextPaymentDueDate`->`periodEnd`

GitOrigin-RevId: c024a3a2cd08c1f8f9d4c99f9ba6f018d334439e
2026-09-17 11:55:52 +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
})
})
})