overleaf/services/web/test/frontend/features/subscription/util/show-downgrade-option.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

47 lines
1.8 KiB
TypeScript

import { expect } from 'chai'
import showDowngradeOption from '../../../../../frontend/js/features/subscription/util/show-downgrade-option'
import dateformat from 'dateformat'
describe('showDowngradeOption', function () {
const today = new Date()
const sevenDaysFromToday = new Date().setDate(today.getDate() + 7)
const sevenDaysFromTodayFormatted = dateformat(
sevenDaysFromToday,
'dS mmmm yyyy'
)
it('returns false when no trial end date', function () {
expect(showDowngradeOption('collab')).to.be.false
})
it('returns false when a plan code without "collaborator" ', function () {
expect(showDowngradeOption('test', false, sevenDaysFromTodayFormatted)).to
.be.false
})
it('returns false when on a plan with trial date in future but has "collaborator" and "ann" in plan code', function () {
expect(
showDowngradeOption(
'collaborator-annual',
false,
sevenDaysFromTodayFormatted
)
).to.be.false
})
it('returns false when on a plan with trial date in future and plan code has "collaborator" and no "ann" but is a group plan', function () {
expect(
showDowngradeOption('collaborator', true, sevenDaysFromTodayFormatted)
).to.be.false
})
it('returns false when on a plan with "collaborator" and without "ann" and trial date in future', function () {
expect(
showDowngradeOption('collaborator', false, sevenDaysFromTodayFormatted)
).to.be.false
})
it('returns true when on a plan with "collaborator" and without "ann" and no trial date', function () {
expect(showDowngradeOption('collaborator', false)).to.be.true
})
it('returns true when on a plan with "collaborator" and without "ann" and trial date is in the past', function () {
expect(
showDowngradeOption('collaborator', false, '2000-02-16T17:59:07.000Z')
).to.be.true
})
})