can-extend-trial.test.ts 1.1 KB

123456789101112131415161718192021222324
  1. import { expect } from 'chai'
  2. import canExtendTrial from '../../../../../frontend/js/features/subscription/util/can-extend-trial'
  3. describe('canExtendTrial', function () {
  4. const d = new Date()
  5. d.setDate(d.getDate() + 6)
  6. it('returns false when no trial end date', function () {
  7. expect(canExtendTrial('collab')).to.be.false
  8. })
  9. it('returns false when a plan code without "collaborator" ', function () {
  10. expect(canExtendTrial('test', false, d.toString())).to.be.false
  11. })
  12. it('returns false when on a plan with trial date in future but has "collaborator" and "ann" in plan code', function () {
  13. expect(canExtendTrial('collaborator-annual', false, d.toString())).to.be
  14. .false
  15. })
  16. 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 () {
  17. expect(canExtendTrial('collaborator', true, d.toString())).to.be.false
  18. })
  19. it('returns true when on a plan with "collaborator" and without "ann" and trial date in future', function () {
  20. expect(canExtendTrial('collaborator', false, d.toString())).to.be.true
  21. })
  22. })