overleaf/services/web/test/frontend/features/subscription/util/is-in-free-trial.test.ts
Alf Eaton 901d79dd55 Merge pull request #19757 from overleaf/ae-eslint-upgrade
Upgrade `@typescript-eslint` dependencies

GitOrigin-RevId: b953e795d705b817ec3669b04cd6a289be12b20d
2024-08-08 08:04:09 +00:00

24 lines
881 B
TypeScript

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 () {
expect(isInFreeTrial()).to.be.false
})
it('returns false when date is null', function () {
expect(isInFreeTrial(null)).to.be.false
})
it('returns false when date is in the past', function () {
expect(isInFreeTrial('2000-02-16T17:59:07.000Z')).to.be.false
})
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
})
})