@ordergroove/offers 2.34.7 → 2.34.8-alpha-PR-784-4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1523,275 +1523,394 @@ describe('productOffer', () => {
1523
1523
  });
1524
1524
  });
1525
1525
 
1526
- describe('productPlans', () => {
1527
- it('should product plans with formatted discounts given action SETUP_PRODUCT', () => {
1528
- const actual = productPlans(
1529
- {},
1530
- {
1531
- type: constants.SETUP_PRODUCT,
1532
- payload: {
1533
- product: {
1534
- id: 'yum product id',
1526
+ function getSetupProductActionForRegularProduct(currency = 'USD') {
1527
+ return {
1528
+ type: constants.SETUP_PRODUCT,
1529
+ payload: {
1530
+ product: {
1531
+ id: 'yum product id',
1532
+ selling_plan_allocations: [
1533
+ {
1534
+ selling_plan_id: 'yum selling plan id 1',
1535
+ compare_at_price: 100,
1536
+ price: 50,
1537
+ price_adjustments: [
1538
+ {
1539
+ value: 50,
1540
+ value_type: 'percentage'
1541
+ }
1542
+ ]
1543
+ }
1544
+ ],
1545
+ variants: [
1546
+ {
1547
+ id: 'yum variant id 1',
1535
1548
  selling_plan_allocations: [
1536
1549
  {
1537
- selling_plan_id: 'yum selling plan id 1',
1538
- compare_at_price: 100,
1539
- price: 50,
1550
+ selling_plan_id: 'yum selling plan id 2',
1551
+ compare_at_price: 50,
1552
+ price: 25,
1540
1553
  price_adjustments: [
1541
1554
  {
1542
- value: 50,
1543
- value_type: 'percentage'
1555
+ value: 25
1544
1556
  }
1545
1557
  ]
1546
1558
  }
1547
- ],
1548
- variants: [
1559
+ ]
1560
+ },
1561
+ {
1562
+ id: 'yum variant id 2',
1563
+ selling_plan_allocations: [
1549
1564
  {
1550
- id: 'yum variant id 1',
1551
- selling_plan_allocations: [
1565
+ selling_plan_id: 'yum selling plan id 3',
1566
+ compare_at_price: 10,
1567
+ price: 8,
1568
+ price_adjustments: []
1569
+ }
1570
+ ]
1571
+ }
1572
+ ],
1573
+ selling_plan_groups: [
1574
+ {
1575
+ selling_plans: [
1576
+ {
1577
+ id: 'yum selling plan id 1',
1578
+ options: [
1552
1579
  {
1553
- selling_plan_id: 'yum selling plan id 2',
1554
- compare_at_price: 50,
1555
- price: 25,
1556
- price_adjustments: [
1557
- {
1558
- value: 25
1559
- }
1560
- ]
1580
+ value: '1 day'
1561
1581
  }
1562
1582
  ]
1563
1583
  },
1564
1584
  {
1565
- id: 'yum variant id 2',
1566
- selling_plan_allocations: [
1585
+ id: 'yum selling plan id 2',
1586
+ options: [
1567
1587
  {
1568
- selling_plan_id: 'yum selling plan id 3',
1569
- compare_at_price: 10,
1570
- price: 8,
1571
- price_adjustments: []
1588
+ value: '1 week'
1572
1589
  }
1573
1590
  ]
1574
- }
1575
- ],
1576
- selling_plan_groups: [
1591
+ },
1577
1592
  {
1578
- selling_plans: [
1579
- {
1580
- id: 'yum selling plan id 1',
1581
- options: [
1582
- {
1583
- value: '1 day'
1584
- }
1585
- ]
1586
- },
1587
- {
1588
- id: 'yum selling plan id 2',
1589
- options: [
1590
- {
1591
- value: '1 week'
1592
- }
1593
- ]
1594
- },
1593
+ id: 'yum selling plan id 3',
1594
+ options: [
1595
1595
  {
1596
- id: 'yum selling plan id 3',
1597
- options: [
1598
- {
1599
- value: '1 month'
1600
- }
1601
- ]
1596
+ value: '1 month'
1602
1597
  }
1603
1598
  ]
1604
1599
  }
1605
1600
  ]
1606
1601
  }
1607
- }
1608
- }
1609
- );
1610
-
1611
- expect(actual).toEqual({
1612
- 'yum product id': [
1613
- {
1614
- frequency: 'yum selling plan id 1',
1615
- prepaidShipments: null,
1616
- regularPrice: '$1.00',
1617
- subscriptionPrice: '$.50',
1618
- discountRate: '50%'
1619
- }
1620
- ],
1621
- 'yum variant id 1': [
1622
- {
1623
- frequency: 'yum selling plan id 2',
1624
- prepaidShipments: null,
1625
- regularPrice: '$.50',
1626
- subscriptionPrice: '$.25',
1627
- discountRate: '$.25'
1628
- }
1629
- ],
1630
- 'yum variant id 2': [
1631
- {
1632
- frequency: 'yum selling plan id 3',
1633
- prepaidShipments: null,
1634
- regularPrice: '$.10',
1635
- subscriptionPrice: '$8',
1636
- discountRate: '$2'
1637
- }
1638
- ]
1639
- });
1640
- });
1641
-
1642
- it('should return product plans with formatted discounts and prepaid info given action SETUP_PRODUCT with prepaid selling plans', () => {
1643
- const actual = productPlans(
1644
- {},
1645
- {
1646
- type: constants.SETUP_PRODUCT,
1647
- payload: {
1648
- product: {
1649
- id: 'yum product id',
1602
+ ]
1603
+ },
1604
+ currency
1605
+ }
1606
+ };
1607
+ }
1608
+
1609
+ function getSetupProductActionForPrepaidProduct(currency = 'USD') {
1610
+ return {
1611
+ type: constants.SETUP_PRODUCT,
1612
+ payload: {
1613
+ product: {
1614
+ id: 'yum product id',
1615
+ selling_plan_allocations: [
1616
+ {
1617
+ selling_plan_id: 'yum selling plan id 1',
1618
+ compare_at_price: 2000,
1619
+ price: 4800,
1620
+ price_adjustments: [
1621
+ {
1622
+ value: 4800
1623
+ }
1624
+ ]
1625
+ }
1626
+ ],
1627
+ variants: [
1628
+ {
1629
+ id: 'yum variant id 1',
1650
1630
  selling_plan_allocations: [
1651
1631
  {
1652
- selling_plan_id: 'yum selling plan id 1',
1653
- compare_at_price: 2000,
1654
- price: 4800,
1632
+ selling_plan_id: 'yum selling plan id 2',
1633
+ compare_at_price: 50,
1634
+ price: 25,
1655
1635
  price_adjustments: [
1656
1636
  {
1657
- value: 4800
1637
+ value: 25
1658
1638
  }
1659
1639
  ]
1640
+ },
1641
+ {
1642
+ selling_plan_id: 'yum selling plan id prepaid 3 shipments',
1643
+ compare_at_price: 50,
1644
+ price: 120
1645
+ },
1646
+ {
1647
+ selling_plan_id: 'yum selling plan id prepaid 6 shipments',
1648
+ compare_at_price: 50,
1649
+ price: 240
1650
+ },
1651
+ {
1652
+ selling_plan_id: 'yum selling plan id prepaid 12 shipments',
1653
+ compare_at_price: 50,
1654
+ price: 480
1660
1655
  }
1661
- ],
1662
- variants: [
1656
+ ]
1657
+ },
1658
+ {
1659
+ id: 'yum variant id 2',
1660
+ selling_plan_allocations: [
1663
1661
  {
1664
- id: 'yum variant id 1',
1665
- selling_plan_allocations: [
1666
- {
1667
- selling_plan_id: 'yum selling plan id 2',
1668
- compare_at_price: 50,
1669
- price: 25,
1670
- price_adjustments: [
1671
- {
1672
- value: 25
1673
- }
1674
- ]
1675
- },
1662
+ selling_plan_id: 'yum selling plan id 3',
1663
+ compare_at_price: 10,
1664
+ price: 8,
1665
+ price_adjustments: []
1666
+ }
1667
+ ]
1668
+ }
1669
+ ],
1670
+ selling_plan_groups: [
1671
+ {
1672
+ selling_plans: [
1673
+ {
1674
+ id: 'yum selling plan id 1',
1675
+ options: [
1676
1676
  {
1677
- selling_plan_id: 'yum selling plan id prepaid 3 shipments',
1678
- compare_at_price: 50,
1679
- price: 120
1677
+ name: 'Delivery every',
1678
+ position: 1,
1679
+ value: 'PREPAID-1 month'
1680
1680
  },
1681
1681
  {
1682
- selling_plan_id: 'yum selling plan id prepaid 6 shipments',
1683
- compare_at_price: 50,
1684
- price: 240
1685
- },
1682
+ name: 'Shipment amount',
1683
+ position: 2,
1684
+ value: '3 shipments'
1685
+ }
1686
+ ]
1687
+ },
1688
+ {
1689
+ id: 'yum selling plan id 2',
1690
+ options: [
1686
1691
  {
1687
- selling_plan_id: 'yum selling plan id prepaid 12 shipments',
1688
- compare_at_price: 50,
1689
- price: 480
1692
+ value: '1 week'
1690
1693
  }
1691
1694
  ]
1692
1695
  },
1693
1696
  {
1694
- id: 'yum variant id 2',
1695
- selling_plan_allocations: [
1697
+ id: 'yum selling plan id 3',
1698
+ options: [
1696
1699
  {
1697
- selling_plan_id: 'yum selling plan id 3',
1698
- compare_at_price: 10,
1699
- price: 8,
1700
- price_adjustments: []
1700
+ value: '1 month'
1701
1701
  }
1702
1702
  ]
1703
1703
  }
1704
- ],
1705
- selling_plan_groups: [
1704
+ ]
1705
+ },
1706
+ {
1707
+ selling_plans: [
1706
1708
  {
1707
- selling_plans: [
1708
- {
1709
- id: 'yum selling plan id 1',
1710
- options: [
1711
- {
1712
- name: 'Delivery every',
1713
- position: 1,
1714
- value: 'PREPAID-1 month'
1715
- },
1716
- {
1717
- name: 'Shipment amount',
1718
- position: 2,
1719
- value: '3 shipments'
1720
- }
1721
- ]
1722
- },
1709
+ id: 'yum selling plan id prepaid 3 shipments',
1710
+ options: [
1723
1711
  {
1724
- id: 'yum selling plan id 2',
1725
- options: [
1726
- {
1727
- value: '1 week'
1728
- }
1729
- ]
1712
+ name: 'Delivery every',
1713
+ position: 1,
1714
+ value: 'PREPAID-1 month'
1730
1715
  },
1731
1716
  {
1732
- id: 'yum selling plan id 3',
1733
- options: [
1734
- {
1735
- value: '1 month'
1736
- }
1737
- ]
1717
+ name: 'Shipment amount',
1718
+ position: 2,
1719
+ value: '3 shipments'
1738
1720
  }
1739
1721
  ]
1740
1722
  },
1741
1723
  {
1742
- selling_plans: [
1724
+ id: 'yum selling plan id prepaid 6 shipments',
1725
+ options: [
1743
1726
  {
1744
- id: 'yum selling plan id prepaid 3 shipments',
1745
- options: [
1746
- {
1747
- name: 'Delivery every',
1748
- position: 1,
1749
- value: 'PREPAID-1 month'
1750
- },
1751
- {
1752
- name: 'Shipment amount',
1753
- position: 2,
1754
- value: '3 shipments'
1755
- }
1756
- ]
1727
+ name: 'Delivery every',
1728
+ position: 1,
1729
+ value: 'PREPAID-1 month'
1757
1730
  },
1758
1731
  {
1759
- id: 'yum selling plan id prepaid 6 shipments',
1760
- options: [
1761
- {
1762
- name: 'Delivery every',
1763
- position: 1,
1764
- value: 'PREPAID-1 month'
1765
- },
1766
- {
1767
- name: 'Shipment amount',
1768
- position: 2,
1769
- value: '6 shipments'
1770
- }
1771
- ]
1732
+ name: 'Shipment amount',
1733
+ position: 2,
1734
+ value: '6 shipments'
1735
+ }
1736
+ ]
1737
+ },
1738
+ {
1739
+ id: 'yum selling plan id prepaid 12 shipments',
1740
+ options: [
1741
+ {
1742
+ name: 'Delivery every',
1743
+ position: 1,
1744
+ value: 'PREPAID-1 month'
1772
1745
  },
1773
1746
  {
1774
- id: 'yum selling plan id prepaid 12 shipments',
1775
- options: [
1776
- {
1777
- name: 'Delivery every',
1778
- position: 1,
1779
- value: 'PREPAID-1 month'
1780
- },
1781
- {
1782
- name: 'Shipment amount',
1783
- position: 2,
1784
- value: '12 shipments'
1785
- }
1786
- ]
1747
+ name: 'Shipment amount',
1748
+ position: 2,
1749
+ value: '12 shipments'
1787
1750
  }
1788
1751
  ]
1789
1752
  }
1790
1753
  ]
1791
1754
  }
1755
+ ]
1756
+ },
1757
+ currency
1758
+ }
1759
+ };
1760
+ }
1761
+
1762
+ function getSetupCartActionForRegularProduct(currency = 'USD') {
1763
+ return {
1764
+ type: constants.SETUP_CART,
1765
+ payload: {
1766
+ items: [
1767
+ {
1768
+ id: 'yum variant id 1',
1769
+ key: 'yum variant key 1',
1770
+ selling_plan_allocation: {
1771
+ selling_plan_id: 'yum selling plan id 2',
1772
+ compare_at_price: 50,
1773
+ price: 25,
1774
+ price_adjustments: [
1775
+ {
1776
+ value: 25
1777
+ }
1778
+ ],
1779
+ selling_plan: {
1780
+ id: 'yum selling plan id 2',
1781
+ options: [
1782
+ {
1783
+ name: 'Delivery every',
1784
+ position: 1,
1785
+ value: '1 day'
1786
+ }
1787
+ ]
1788
+ }
1789
+ }
1790
+ },
1791
+ {
1792
+ id: 'yum variant id 2',
1793
+ key: 'yum variant key 2',
1794
+ selling_plan_allocation: {
1795
+ selling_plan_id: 'yum selling plan id 3',
1796
+ compare_at_price: 10,
1797
+ price: 8,
1798
+ price_adjustments: [],
1799
+ selling_plan: {
1800
+ id: 'yum selling plan id 3',
1801
+ options: [
1802
+ {
1803
+ name: 'Delivery every',
1804
+ position: 1,
1805
+ value: '1 month'
1806
+ }
1807
+ ]
1808
+ }
1809
+ }
1792
1810
  }
1793
- }
1794
- );
1811
+ ],
1812
+ currency
1813
+ }
1814
+ };
1815
+ }
1816
+
1817
+ function getSetupCartActionForPrepaidProduct(currency = 'USD') {
1818
+ return {
1819
+ type: constants.SETUP_CART,
1820
+ payload: {
1821
+ items: [
1822
+ {
1823
+ id: 'yum variant id 1',
1824
+ key: 'yum variant key 1',
1825
+ selling_plan_allocation: {
1826
+ selling_plan_id: 'yum prepaid selling plan id',
1827
+ compare_at_price: 50,
1828
+ price: 480,
1829
+ price_adjustments: [
1830
+ {
1831
+ value: 480
1832
+ }
1833
+ ],
1834
+ selling_plan: {
1835
+ id: 'yum prepaid selling plan id',
1836
+ options: [
1837
+ {
1838
+ name: 'Delivery every',
1839
+ position: 1,
1840
+ value: '1 day'
1841
+ },
1842
+ {
1843
+ name: 'Shipment amount',
1844
+ position: 2,
1845
+ value: '12 shipments'
1846
+ }
1847
+ ]
1848
+ }
1849
+ }
1850
+ },
1851
+ {
1852
+ id: 'yum variant id 2',
1853
+ key: 'yum variant key 2',
1854
+ selling_plan_allocation: {
1855
+ selling_plan_id: 'yum selling plan id 3',
1856
+ compare_at_price: 10,
1857
+ price: 8,
1858
+ price_adjustments: [],
1859
+ selling_plan: {
1860
+ id: 'yum selling plan id 3',
1861
+ options: [
1862
+ {
1863
+ name: 'Delivery every',
1864
+ position: 1,
1865
+ value: '1 month'
1866
+ }
1867
+ ]
1868
+ }
1869
+ }
1870
+ }
1871
+ ],
1872
+ currency
1873
+ }
1874
+ };
1875
+ }
1876
+
1877
+ describe('productPlans', () => {
1878
+ it('should return product plans with formatted discounts given action SETUP_PRODUCT', () => {
1879
+ const actual = productPlans({}, getSetupProductActionForRegularProduct());
1880
+
1881
+ expect(actual).toEqual({
1882
+ 'yum product id': [
1883
+ {
1884
+ frequency: 'yum selling plan id 1',
1885
+ prepaidShipments: null,
1886
+ regularPrice: '$1.00',
1887
+ subscriptionPrice: '$0.50',
1888
+ discountRate: '50%'
1889
+ }
1890
+ ],
1891
+ 'yum variant id 1': [
1892
+ {
1893
+ frequency: 'yum selling plan id 2',
1894
+ prepaidShipments: null,
1895
+ regularPrice: '$0.50',
1896
+ subscriptionPrice: '$0.25',
1897
+ discountRate: '$0.25'
1898
+ }
1899
+ ],
1900
+ 'yum variant id 2': [
1901
+ {
1902
+ frequency: 'yum selling plan id 3',
1903
+ prepaidShipments: null,
1904
+ regularPrice: '$0.10',
1905
+ subscriptionPrice: '$0.08',
1906
+ discountRate: '$0.02'
1907
+ }
1908
+ ]
1909
+ });
1910
+ });
1911
+
1912
+ it('should return product plans with formatted discounts and prepaid info given action SETUP_PRODUCT with prepaid selling plans', () => {
1913
+ const actual = productPlans({}, getSetupProductActionForPrepaidProduct());
1795
1914
 
1796
1915
  expect(actual).toEqual({
1797
1916
  'yum product id': [
@@ -1809,203 +1928,126 @@ describe('productPlans', () => {
1809
1928
  'yum variant id 1': [
1810
1929
  {
1811
1930
  frequency: 'yum selling plan id 2',
1812
- regularPrice: '$.50',
1813
- subscriptionPrice: '$.25',
1814
- discountRate: '$.25',
1931
+ regularPrice: '$0.50',
1932
+ subscriptionPrice: '$0.25',
1933
+ discountRate: '$0.25',
1815
1934
  prepaidShipments: null
1816
1935
  },
1817
1936
  {
1818
1937
  frequency: 'yum selling plan id prepaid 3 shipments',
1819
- regularPrice: '$.50',
1820
- subscriptionPrice: '$.40',
1938
+ regularPrice: '$0.50',
1939
+ subscriptionPrice: '$0.40',
1821
1940
  discountRate: '20%',
1822
1941
  prepaidShipments: 3,
1823
1942
  regularPrepaidPrice: '$1.20',
1824
- prepaidSavingsPerShipment: '$.10',
1825
- prepaidSavingsTotal: '$.30'
1943
+ prepaidSavingsPerShipment: '$0.10',
1944
+ prepaidSavingsTotal: '$0.30'
1826
1945
  },
1827
1946
  {
1828
1947
  frequency: 'yum selling plan id prepaid 6 shipments',
1829
- regularPrice: '$.50',
1830
- subscriptionPrice: '$.40',
1948
+ regularPrice: '$0.50',
1949
+ subscriptionPrice: '$0.40',
1831
1950
  discountRate: '20%',
1832
1951
  prepaidShipments: 6,
1833
1952
  regularPrepaidPrice: '$2.40',
1834
- prepaidSavingsPerShipment: '$.10',
1835
- prepaidSavingsTotal: '$.60'
1953
+ prepaidSavingsPerShipment: '$0.10',
1954
+ prepaidSavingsTotal: '$0.60'
1836
1955
  },
1837
1956
  {
1838
1957
  frequency: 'yum selling plan id prepaid 12 shipments',
1839
- regularPrice: '$.50',
1840
- subscriptionPrice: '$.40',
1958
+ regularPrice: '$0.50',
1959
+ subscriptionPrice: '$0.40',
1841
1960
  discountRate: '20%',
1842
1961
  prepaidShipments: 12,
1843
1962
  regularPrepaidPrice: '$4.80',
1844
- prepaidSavingsPerShipment: '$.10',
1963
+ prepaidSavingsPerShipment: '$0.10',
1845
1964
  prepaidSavingsTotal: '$1.20'
1846
1965
  }
1847
1966
  ],
1848
1967
  'yum variant id 2': [
1849
1968
  {
1850
1969
  frequency: 'yum selling plan id 3',
1851
- regularPrice: '$.10',
1852
- subscriptionPrice: '$8',
1853
- discountRate: '$2',
1970
+ regularPrice: '$0.10',
1971
+ subscriptionPrice: '$0.08',
1972
+ discountRate: '$0.02',
1854
1973
  prepaidShipments: null
1855
1974
  }
1856
1975
  ]
1857
1976
  });
1858
1977
  });
1859
1978
 
1860
- it('should product plans with formatted discounts given action SETUP_CART', () => {
1861
- const actual = productPlans(
1862
- {},
1863
- {
1864
- type: constants.SETUP_CART,
1865
- payload: {
1866
- items: [
1867
- {
1868
- id: 'yum variant id 1',
1869
- key: 'yum variant key 1',
1870
- selling_plan_allocation: {
1871
- selling_plan_id: 'yum selling plan id 2',
1872
- compare_at_price: 50,
1873
- price: 25,
1874
- price_adjustments: [
1875
- {
1876
- value: 25
1877
- }
1878
- ],
1879
- selling_plan: {
1880
- id: 'yum selling plan id 2',
1881
- options: [
1882
- {
1883
- name: 'Delivery every',
1884
- position: 1,
1885
- value: '1 day'
1886
- }
1887
- ]
1888
- }
1889
- }
1890
- },
1891
- {
1892
- id: 'yum variant id 2',
1893
- key: 'yum variant key 2',
1894
- selling_plan_allocation: {
1895
- selling_plan_id: 'yum selling plan id 3',
1896
- compare_at_price: 10,
1897
- price: 8,
1898
- price_adjustments: [],
1899
- selling_plan: {
1900
- id: 'yum selling plan id 3',
1901
- options: [
1902
- {
1903
- name: 'Delivery every',
1904
- position: 1,
1905
- value: '1 month'
1906
- }
1907
- ]
1908
- }
1909
- }
1910
- }
1911
- ]
1979
+ it('should convert product plan values into non-USD currencies given action SETUP_PRODUCT with GBP currency', () => {
1980
+ const actual = productPlans({}, getSetupProductActionForRegularProduct('GBP'));
1981
+
1982
+ expect(actual).toEqual({
1983
+ 'yum product id': [
1984
+ {
1985
+ frequency: 'yum selling plan id 1',
1986
+ prepaidShipments: null,
1987
+ regularPrice: '£1.00',
1988
+ subscriptionPrice: '£0.50',
1989
+ discountRate: '50%'
1912
1990
  }
1913
- }
1914
- );
1991
+ ],
1992
+ 'yum variant id 1': [
1993
+ {
1994
+ frequency: 'yum selling plan id 2',
1995
+ prepaidShipments: null,
1996
+ regularPrice: '£0.50',
1997
+ subscriptionPrice: '£0.25',
1998
+ discountRate: '£0.25'
1999
+ }
2000
+ ],
2001
+ 'yum variant id 2': [
2002
+ {
2003
+ frequency: 'yum selling plan id 3',
2004
+ prepaidShipments: null,
2005
+ regularPrice: '£0.10',
2006
+ subscriptionPrice: '£0.08',
2007
+ discountRate: '£0.02'
2008
+ }
2009
+ ]
2010
+ });
2011
+ });
2012
+
2013
+ it('should return product plans with formatted discounts given action SETUP_CART', () => {
2014
+ const actual = productPlans({}, getSetupCartActionForRegularProduct());
1915
2015
 
1916
2016
  expect(actual).toEqual({
1917
2017
  'yum variant key 1': [
1918
2018
  {
1919
2019
  frequency: 'yum selling plan id 2',
1920
2020
  prepaidShipments: null,
1921
- regularPrice: '$.50',
1922
- subscriptionPrice: '$.25',
1923
- discountRate: '$.25'
2021
+ regularPrice: '$0.50',
2022
+ subscriptionPrice: '$0.25',
2023
+ discountRate: '$0.25'
1924
2024
  }
1925
2025
  ],
1926
2026
  'yum variant key 2': [
1927
2027
  {
1928
2028
  frequency: 'yum selling plan id 3',
1929
2029
  prepaidShipments: null,
1930
- regularPrice: '$.10',
1931
- subscriptionPrice: '$8',
1932
- discountRate: '$2'
2030
+ regularPrice: '$0.10',
2031
+ subscriptionPrice: '$0.08',
2032
+ discountRate: '$0.02'
1933
2033
  }
1934
2034
  ]
1935
2035
  });
1936
2036
  });
1937
2037
 
1938
- it('should product plans with formatted discounts and prepaid info given action SETUP_CART with prepaid selling plans', () => {
1939
- const actual = productPlans(
1940
- {},
1941
- {
1942
- type: constants.SETUP_CART,
1943
- payload: {
1944
- items: [
1945
- {
1946
- id: 'yum variant id 1',
1947
- key: 'yum variant key 1',
1948
- selling_plan_allocation: {
1949
- selling_plan_id: 'yum prepaid selling plan id',
1950
- compare_at_price: 50,
1951
- price: 480,
1952
- price_adjustments: [
1953
- {
1954
- value: 480
1955
- }
1956
- ],
1957
- selling_plan: {
1958
- id: 'yum prepaid selling plan id',
1959
- options: [
1960
- {
1961
- name: 'Delivery every',
1962
- position: 1,
1963
- value: '1 day'
1964
- },
1965
- {
1966
- name: 'Shipment amount',
1967
- position: 2,
1968
- value: '12 shipments'
1969
- }
1970
- ]
1971
- }
1972
- }
1973
- },
1974
- {
1975
- id: 'yum variant id 2',
1976
- key: 'yum variant key 2',
1977
- selling_plan_allocation: {
1978
- selling_plan_id: 'yum selling plan id 3',
1979
- compare_at_price: 10,
1980
- price: 8,
1981
- price_adjustments: [],
1982
- selling_plan: {
1983
- id: 'yum selling plan id 3',
1984
- options: [
1985
- {
1986
- name: 'Delivery every',
1987
- position: 1,
1988
- value: '1 month'
1989
- }
1990
- ]
1991
- }
1992
- }
1993
- }
1994
- ]
1995
- }
1996
- }
1997
- );
2038
+ it('should return product plans with formatted discounts and prepaid info given action SETUP_CART with prepaid selling plans', () => {
2039
+ const actual = productPlans({}, getSetupCartActionForPrepaidProduct());
1998
2040
 
1999
2041
  expect(actual).toEqual({
2000
2042
  'yum variant key 1': [
2001
2043
  {
2002
2044
  frequency: 'yum prepaid selling plan id',
2003
- regularPrice: '$.50',
2004
- subscriptionPrice: '$.40',
2045
+ regularPrice: '$0.50',
2046
+ subscriptionPrice: '$0.40',
2005
2047
  discountRate: '20%',
2006
2048
  prepaidShipments: 12,
2007
2049
  regularPrepaidPrice: '$4.80',
2008
- prepaidSavingsPerShipment: '$.10',
2050
+ prepaidSavingsPerShipment: '$0.10',
2009
2051
  prepaidSavingsTotal: '$1.20'
2010
2052
  }
2011
2053
  ],
@@ -2013,9 +2055,34 @@ describe('productPlans', () => {
2013
2055
  {
2014
2056
  frequency: 'yum selling plan id 3',
2015
2057
  prepaidShipments: null,
2016
- regularPrice: '$.10',
2017
- subscriptionPrice: '$8',
2018
- discountRate: '$2'
2058
+ regularPrice: '$0.10',
2059
+ subscriptionPrice: '$0.08',
2060
+ discountRate: '$0.02'
2061
+ }
2062
+ ]
2063
+ });
2064
+ });
2065
+
2066
+ it('should convert product plan values into non-USD currencies given action SETUP_PRODUCT with GBP currency', () => {
2067
+ const actual = productPlans({}, getSetupCartActionForRegularProduct('GBP'));
2068
+
2069
+ expect(actual).toEqual({
2070
+ 'yum variant key 1': [
2071
+ {
2072
+ frequency: 'yum selling plan id 2',
2073
+ prepaidShipments: null,
2074
+ regularPrice: '£0.50',
2075
+ subscriptionPrice: '£0.25',
2076
+ discountRate: '£0.25'
2077
+ }
2078
+ ],
2079
+ 'yum variant key 2': [
2080
+ {
2081
+ frequency: 'yum selling plan id 3',
2082
+ prepaidShipments: null,
2083
+ regularPrice: '£0.10',
2084
+ subscriptionPrice: '£0.08',
2085
+ discountRate: '£0.02'
2019
2086
  }
2020
2087
  ]
2021
2088
  });