group-plan-pricing.test.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 = window.metaAttributesCache || new Map()
  6. window.metaAttributesCache.set('ol-groupPlans', {
  7. enterprise: {
  8. professional: {
  9. CHF: {
  10. 2: {
  11. price_in_cents: 10000,
  12. },
  13. },
  14. DKK: {
  15. 2: {
  16. price_in_cents: 20000,
  17. },
  18. },
  19. USD: {
  20. 2: {
  21. price_in_cents: 30000,
  22. },
  23. },
  24. },
  25. },
  26. })
  27. window.metaAttributesCache.set('ol-currencySymbols', {
  28. CHF: 'Fr',
  29. DKK: 'kr',
  30. USD: '$',
  31. })
  32. })
  33. afterEach(function () {
  34. window.metaAttributesCache = new Map()
  35. })
  36. describe('createLocalizedGroupPlanPrice', function () {
  37. describe('CHF currency', function () {
  38. it('should return the correct localized price', function () {
  39. const localizedGroupPlanPrice = createLocalizedGroupPlanPrice({
  40. plan: 'professional',
  41. currency: 'CHF',
  42. licenseSize: '2',
  43. usage: 'enterprise',
  44. })
  45. expect(localizedGroupPlanPrice).to.deep.equal({
  46. localizedPrice: 'Fr 100',
  47. localizedPerUserPrice: 'Fr 50',
  48. })
  49. })
  50. })
  51. describe('DKK currency', function () {
  52. it('should return the correct localized price', function () {
  53. const localizedGroupPlanPrice = createLocalizedGroupPlanPrice({
  54. plan: 'professional',
  55. currency: 'DKK',
  56. licenseSize: '2',
  57. usage: 'enterprise',
  58. })
  59. expect(localizedGroupPlanPrice).to.deep.equal({
  60. localizedPrice: '200 kr',
  61. localizedPerUserPrice: '100 kr',
  62. })
  63. })
  64. })
  65. describe('other supported currencies', function () {
  66. it('should return the correct localized price', function () {
  67. const localizedGroupPlanPrice = createLocalizedGroupPlanPrice({
  68. plan: 'professional',
  69. currency: 'USD',
  70. licenseSize: '2',
  71. usage: 'enterprise',
  72. })
  73. expect(localizedGroupPlanPrice).to.deep.equal({
  74. localizedPrice: '$300',
  75. localizedPerUserPrice: '$150',
  76. })
  77. })
  78. })
  79. })
  80. })