group-plan-pricing.test.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { expect } from 'chai'
  2. import { createLocalizedGroupPlanPrice } from '../../../../frontend/js/features/plans/utils/group-plan-pricing'
  3. describe('group-plan-pricing', function () {
  4. beforeEach(function () {
  5. window.metaAttributesCache.set('ol-groupPlans', {
  6. enterprise: {
  7. professional: {
  8. CHF: {
  9. 2: {
  10. price_in_cents: 10000,
  11. },
  12. },
  13. DKK: {
  14. 2: {
  15. price_in_cents: 20000,
  16. },
  17. },
  18. USD: {
  19. 2: {
  20. price_in_cents: 30000,
  21. },
  22. },
  23. },
  24. },
  25. })
  26. window.metaAttributesCache.set('ol-i18n', { currentLangCode: 'en' })
  27. })
  28. describe('createLocalizedGroupPlanPrice', function () {
  29. describe('CHF currency', function () {
  30. it('should return the correct localized price', function () {
  31. const localizedGroupPlanPrice = createLocalizedGroupPlanPrice({
  32. plan: 'professional',
  33. currency: 'CHF',
  34. licenseSize: '2',
  35. usage: 'enterprise',
  36. })
  37. expect(localizedGroupPlanPrice).to.deep.equal({
  38. localizedPrice: 'CHF 100',
  39. localizedPerUserPrice: 'CHF 50',
  40. })
  41. })
  42. })
  43. describe('DKK currency', function () {
  44. it('should return the correct localized price', function () {
  45. const localizedGroupPlanPrice = createLocalizedGroupPlanPrice({
  46. plan: 'professional',
  47. currency: 'DKK',
  48. licenseSize: '2',
  49. usage: 'enterprise',
  50. })
  51. expect(localizedGroupPlanPrice).to.deep.equal({
  52. localizedPrice: 'kr 200',
  53. localizedPerUserPrice: 'kr 100',
  54. })
  55. })
  56. })
  57. describe('other supported currencies', function () {
  58. it('should return the correct localized price', function () {
  59. const localizedGroupPlanPrice = createLocalizedGroupPlanPrice({
  60. plan: 'professional',
  61. currency: 'USD',
  62. licenseSize: '2',
  63. usage: 'enterprise',
  64. })
  65. expect(localizedGroupPlanPrice).to.deep.equal({
  66. localizedPrice: '$300',
  67. localizedPerUserPrice: '$150',
  68. })
  69. })
  70. })
  71. })
  72. })