2022-07-07 09:36:25 -04:00
|
|
|
|
import { expect } from 'chai'
|
|
|
|
|
import { createLocalizedGroupPlanPrice } from '../../../../frontend/js/features/plans/utils/group-plan-pricing'
|
2024-04-18 04:13:51 -04:00
|
|
|
|
import { formatCurrencyLocalized } from '@/shared/utils/currency'
|
2022-07-07 09:36:25 -04:00
|
|
|
|
|
|
|
|
|
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-currencySymbols', {
|
|
|
|
|
CHF: 'Fr',
|
|
|
|
|
DKK: 'kr',
|
|
|
|
|
USD: '$',
|
|
|
|
|
})
|
2024-06-18 06:01:37 -04:00
|
|
|
|
window.metaAttributesCache.set('ol-i18n', { currentLangCode: 'en' })
|
2022-07-07 09:36:25 -04:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
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',
|
2024-04-18 04:13:51 -04:00
|
|
|
|
formatCurrency: formatCurrencyLocalized,
|
2022-07-07 09:36:25 -04:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
expect(localizedGroupPlanPrice).to.deep.equal({
|
2024-04-18 04:13:51 -04:00
|
|
|
|
localizedPrice: 'CHF 100',
|
|
|
|
|
localizedPerUserPrice: 'CHF 50',
|
2022-07-07 09:36:25 -04:00
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
describe('DKK currency', function () {
|
|
|
|
|
it('should return the correct localized price', function () {
|
|
|
|
|
const localizedGroupPlanPrice = createLocalizedGroupPlanPrice({
|
|
|
|
|
plan: 'professional',
|
|
|
|
|
currency: 'DKK',
|
|
|
|
|
licenseSize: '2',
|
|
|
|
|
usage: 'enterprise',
|
2024-04-18 04:13:51 -04:00
|
|
|
|
formatCurrency: formatCurrencyLocalized,
|
2022-07-07 09:36:25 -04:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
expect(localizedGroupPlanPrice).to.deep.equal({
|
2024-04-18 04:13:51 -04:00
|
|
|
|
localizedPrice: 'kr 200',
|
|
|
|
|
localizedPerUserPrice: 'kr 100',
|
2022-07-07 09:36:25 -04:00
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
describe('other supported currencies', function () {
|
|
|
|
|
it('should return the correct localized price', function () {
|
|
|
|
|
const localizedGroupPlanPrice = createLocalizedGroupPlanPrice({
|
|
|
|
|
plan: 'professional',
|
|
|
|
|
currency: 'USD',
|
|
|
|
|
licenseSize: '2',
|
|
|
|
|
usage: 'enterprise',
|
2024-04-18 04:13:51 -04:00
|
|
|
|
formatCurrency: formatCurrencyLocalized,
|
2022-07-07 09:36:25 -04:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
expect(localizedGroupPlanPrice).to.deep.equal({
|
|
|
|
|
localizedPrice: '$300',
|
|
|
|
|
localizedPerUserPrice: '$150',
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|