| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- import { expect } from 'chai'
- import { createLocalizedGroupPlanPrice } from '../../../../frontend/js/features/plans/utils/group-plan-pricing'
- import { formatCurrencyLocalized } from '@/shared/utils/currency'
- describe('group-plan-pricing', function () {
- beforeEach(function () {
- window.metaAttributesCache = window.metaAttributesCache || new Map()
- 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: '$',
- })
- })
- afterEach(function () {
- window.metaAttributesCache = new Map()
- })
- 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',
- formatCurrency: formatCurrencyLocalized,
- })
- 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',
- formatCurrency: formatCurrencyLocalized,
- })
- 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',
- formatCurrency: formatCurrencyLocalized,
- })
- expect(localizedGroupPlanPrice).to.deep.equal({
- localizedPrice: '$300',
- localizedPerUserPrice: '$150',
- })
- })
- })
- })
- })
|