mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
* Reapply "[web] Remove SubscriptionFormatters, format subscription dates in the…" This reverts commit 2939e71e5b919529cbb8a602916d5f597d117792. * Fixup after rename conflict: `nextPaymentDueDate`->`periodEnd` GitOrigin-RevId: c024a3a2cd08c1f8f9d4c99f9ba6f018d334439e
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { expect } from 'chai'
|
||||
import isInFreeTrial from '../../../../../frontend/js/features/subscription/util/is-in-free-trial'
|
||||
import dateformat from 'dateformat'
|
||||
|
||||
describe('isInFreeTrial', function () {
|
||||
it('returns false when no date sent', function () {
|
||||
@@ -15,10 +14,6 @@ describe('isInFreeTrial', function () {
|
||||
it('returns true when date is in the future', function () {
|
||||
const today = new Date()
|
||||
const sevenDaysFromToday = new Date().setDate(today.getDate() + 7)
|
||||
const sevenDaysFromTodayFormatted = dateformat(
|
||||
sevenDaysFromToday,
|
||||
'dS mmmm yyyy'
|
||||
)
|
||||
expect(isInFreeTrial(sevenDaysFromTodayFormatted)).to.be.true
|
||||
expect(isInFreeTrial(new Date(sevenDaysFromToday).toISOString())).to.be.true
|
||||
})
|
||||
})
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
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
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user