mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
[web] Subscription event segmentation GitOrigin-RevId: fdc25ac7bc7320ed82617b7c27c12a17eb31d723
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import { expect } from 'chai'
|
|
import getSubscriptionEventSegmentation from '../../../../../frontend/js/features/subscription/util/subscription-event-segmentation'
|
|
import {
|
|
annualActiveSubscriptionEuro,
|
|
monthlyActiveCollaborator,
|
|
trialCollaboratorSubscription,
|
|
} from '../fixtures/subscriptions'
|
|
|
|
describe('getSubscriptionEventSegmentation', function () {
|
|
it('segments a monthly subscription', function () {
|
|
expect(
|
|
getSubscriptionEventSegmentation(monthlyActiveCollaborator)
|
|
).to.deep.equal({
|
|
plan_code: 'collaborator',
|
|
billing_cycle: 'monthly',
|
|
is_trial: false,
|
|
currency: 'USD',
|
|
})
|
|
})
|
|
|
|
it('segments an annual subscription', function () {
|
|
expect(
|
|
getSubscriptionEventSegmentation(annualActiveSubscriptionEuro)
|
|
).to.deep.equal({
|
|
plan_code: 'collaborator-annual',
|
|
billing_cycle: 'annual',
|
|
is_trial: false,
|
|
currency: 'EUR',
|
|
})
|
|
})
|
|
|
|
it('segments a subscription in a free trial', function () {
|
|
expect(
|
|
getSubscriptionEventSegmentation(trialCollaboratorSubscription)
|
|
).to.deep.equal({
|
|
plan_code: 'collaborator_free_trial_7_days',
|
|
billing_cycle: 'monthly',
|
|
is_trial: true,
|
|
currency: 'USD',
|
|
})
|
|
})
|
|
|
|
it('omits the plan segmentation without a subscription', function () {
|
|
expect(getSubscriptionEventSegmentation(undefined)).to.deep.equal({
|
|
plan_code: undefined,
|
|
billing_cycle: undefined,
|
|
is_trial: false,
|
|
currency: undefined,
|
|
})
|
|
})
|
|
})
|