Files
overleaf-cep/services/web/test/frontend/shared/utils/group-plan-pricing.test.js
T
M Fahru 2ef5db2938 Merge pull request #22340 from overleaf/mf-clean-up-currency-format-test
[web] Clean up localized currency format test (`local-ccy-format-v2`)

GitOrigin-RevId: 30d671479522b87ee9205994508b745d2b0ae4c3
2025-01-14 09:05:49 +00:00

78 lines
2.2 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { expect } from 'chai'
import { createLocalizedGroupPlanPrice } from '../../../../frontend/js/features/plans/utils/group-plan-pricing'
describe('group-plan-pricing', function () {
beforeEach(function () {
window.metaAttributesCache.set('ol-groupPlans', {
enterprise: {
professional: {
CHF: {
2: {
price_in_cents: 10000,
},
},
DKK: {
2: {
price_in_cents: 20000,
},
},
USD: {
2: {
price_in_cents: 30000,
},
},
},
},
})
window.metaAttributesCache.set('ol-i18n', { currentLangCode: 'en' })
})
describe('createLocalizedGroupPlanPrice', function () {
describe('CHF currency', function () {
it('should return the correct localized price', function () {
const localizedGroupPlanPrice = createLocalizedGroupPlanPrice({
plan: 'professional',
currency: 'CHF',
licenseSize: '2',
usage: 'enterprise',
})
expect(localizedGroupPlanPrice).to.deep.equal({
localizedPrice: 'CHF 100',
localizedPerUserPrice: 'CHF 50',
})
})
})
describe('DKK currency', function () {
it('should return the correct localized price', function () {
const localizedGroupPlanPrice = createLocalizedGroupPlanPrice({
plan: 'professional',
currency: 'DKK',
licenseSize: '2',
usage: 'enterprise',
})
expect(localizedGroupPlanPrice).to.deep.equal({
localizedPrice: 'kr 200',
localizedPerUserPrice: 'kr 100',
})
})
})
describe('other supported currencies', function () {
it('should return the correct localized price', function () {
const localizedGroupPlanPrice = createLocalizedGroupPlanPrice({
plan: 'professional',
currency: 'USD',
licenseSize: '2',
usage: 'enterprise',
})
expect(localizedGroupPlanPrice).to.deep.equal({
localizedPrice: '$300',
localizedPerUserPrice: '$150',
})
})
})
})
})