@ordergroove/offers 2.34.8-alpha-PR-784-7.8 → 2.34.9
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.
- package/CHANGELOG.md +19 -0
- package/dist/bundle-report.html +16 -16
- package/dist/examples.js.map +2 -2
- package/dist/offers.js +28 -28
- package/dist/offers.js.map +3 -3
- package/examples/index.js +1 -0
- package/package.json +2 -2
- package/src/components/PrepaidData.js +9 -6
- package/src/components/__tests__/PrepaidData.spec.js +23 -4
- package/src/shopify/__tests__/productPlan.spec.js +13 -13
- package/src/shopify/__tests__/shopifyReducer.spec.js +350 -417
- package/src/shopify/__tests__/utils.spec.js +3 -7
- package/src/shopify/reducers/productPlans.ts +19 -22
- package/src/shopify/shopifyBootstrap.ts +1 -9
- package/src/shopify/shopifyMiddleware.ts +3 -13
- package/src/shopify/shopifyReducer.js +3 -3
- package/src/shopify/types/shopify.ts +3 -3
- package/src/shopify/utils.ts +1 -7
|
@@ -1523,394 +1523,275 @@ describe('productOffer', () => {
|
|
|
1523
1523
|
});
|
|
1524
1524
|
});
|
|
1525
1525
|
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
{
|
|
1534
|
-
|
|
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',
|
|
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',
|
|
1548
1535
|
selling_plan_allocations: [
|
|
1549
1536
|
{
|
|
1550
|
-
selling_plan_id: 'yum selling plan id
|
|
1551
|
-
compare_at_price:
|
|
1552
|
-
price:
|
|
1537
|
+
selling_plan_id: 'yum selling plan id 1',
|
|
1538
|
+
compare_at_price: 100,
|
|
1539
|
+
price: 50,
|
|
1553
1540
|
price_adjustments: [
|
|
1554
1541
|
{
|
|
1555
|
-
value:
|
|
1542
|
+
value: 50,
|
|
1543
|
+
value_type: 'percentage'
|
|
1556
1544
|
}
|
|
1557
1545
|
]
|
|
1558
1546
|
}
|
|
1559
|
-
]
|
|
1560
|
-
|
|
1561
|
-
{
|
|
1562
|
-
id: 'yum variant id 2',
|
|
1563
|
-
selling_plan_allocations: [
|
|
1564
|
-
{
|
|
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: [
|
|
1547
|
+
],
|
|
1548
|
+
variants: [
|
|
1576
1549
|
{
|
|
1577
|
-
id: 'yum
|
|
1578
|
-
|
|
1550
|
+
id: 'yum variant id 1',
|
|
1551
|
+
selling_plan_allocations: [
|
|
1579
1552
|
{
|
|
1580
|
-
|
|
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
|
+
]
|
|
1581
1561
|
}
|
|
1582
1562
|
]
|
|
1583
1563
|
},
|
|
1584
1564
|
{
|
|
1585
|
-
id: 'yum
|
|
1586
|
-
|
|
1565
|
+
id: 'yum variant id 2',
|
|
1566
|
+
selling_plan_allocations: [
|
|
1587
1567
|
{
|
|
1588
|
-
|
|
1568
|
+
selling_plan_id: 'yum selling plan id 3',
|
|
1569
|
+
compare_at_price: 10,
|
|
1570
|
+
price: 8,
|
|
1571
|
+
price_adjustments: []
|
|
1589
1572
|
}
|
|
1590
1573
|
]
|
|
1591
|
-
}
|
|
1574
|
+
}
|
|
1575
|
+
],
|
|
1576
|
+
selling_plan_groups: [
|
|
1592
1577
|
{
|
|
1593
|
-
|
|
1594
|
-
options: [
|
|
1578
|
+
selling_plans: [
|
|
1595
1579
|
{
|
|
1596
|
-
|
|
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
|
+
},
|
|
1595
|
+
{
|
|
1596
|
+
id: 'yum selling plan id 3',
|
|
1597
|
+
options: [
|
|
1598
|
+
{
|
|
1599
|
+
value: '1 month'
|
|
1600
|
+
}
|
|
1601
|
+
]
|
|
1597
1602
|
}
|
|
1598
1603
|
]
|
|
1599
1604
|
}
|
|
1600
1605
|
]
|
|
1601
1606
|
}
|
|
1602
|
-
|
|
1603
|
-
}
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
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',
|
|
1630
1650
|
selling_plan_allocations: [
|
|
1631
1651
|
{
|
|
1632
|
-
selling_plan_id: 'yum selling plan id
|
|
1633
|
-
compare_at_price:
|
|
1634
|
-
price:
|
|
1652
|
+
selling_plan_id: 'yum selling plan id 1',
|
|
1653
|
+
compare_at_price: 2000,
|
|
1654
|
+
price: 4800,
|
|
1635
1655
|
price_adjustments: [
|
|
1636
1656
|
{
|
|
1637
|
-
value:
|
|
1657
|
+
value: 4800
|
|
1638
1658
|
}
|
|
1639
1659
|
]
|
|
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
|
|
1655
|
-
}
|
|
1656
|
-
]
|
|
1657
|
-
},
|
|
1658
|
-
{
|
|
1659
|
-
id: 'yum variant id 2',
|
|
1660
|
-
selling_plan_allocations: [
|
|
1661
|
-
{
|
|
1662
|
-
selling_plan_id: 'yum selling plan id 3',
|
|
1663
|
-
compare_at_price: 10,
|
|
1664
|
-
price: 8,
|
|
1665
|
-
price_adjustments: []
|
|
1666
1660
|
}
|
|
1667
|
-
]
|
|
1668
|
-
|
|
1669
|
-
],
|
|
1670
|
-
selling_plan_groups: [
|
|
1671
|
-
{
|
|
1672
|
-
selling_plans: [
|
|
1661
|
+
],
|
|
1662
|
+
variants: [
|
|
1673
1663
|
{
|
|
1674
|
-
id: 'yum
|
|
1675
|
-
|
|
1664
|
+
id: 'yum variant id 1',
|
|
1665
|
+
selling_plan_allocations: [
|
|
1676
1666
|
{
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
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
|
+
]
|
|
1680
1675
|
},
|
|
1681
1676
|
{
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
}
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1677
|
+
selling_plan_id: 'yum selling plan id prepaid 3 shipments',
|
|
1678
|
+
compare_at_price: 50,
|
|
1679
|
+
price: 120
|
|
1680
|
+
},
|
|
1681
|
+
{
|
|
1682
|
+
selling_plan_id: 'yum selling plan id prepaid 6 shipments',
|
|
1683
|
+
compare_at_price: 50,
|
|
1684
|
+
price: 240
|
|
1685
|
+
},
|
|
1691
1686
|
{
|
|
1692
|
-
|
|
1687
|
+
selling_plan_id: 'yum selling plan id prepaid 12 shipments',
|
|
1688
|
+
compare_at_price: 50,
|
|
1689
|
+
price: 480
|
|
1693
1690
|
}
|
|
1694
1691
|
]
|
|
1695
1692
|
},
|
|
1696
1693
|
{
|
|
1697
|
-
id: 'yum
|
|
1698
|
-
|
|
1694
|
+
id: 'yum variant id 2',
|
|
1695
|
+
selling_plan_allocations: [
|
|
1699
1696
|
{
|
|
1700
|
-
|
|
1697
|
+
selling_plan_id: 'yum selling plan id 3',
|
|
1698
|
+
compare_at_price: 10,
|
|
1699
|
+
price: 8,
|
|
1700
|
+
price_adjustments: []
|
|
1701
1701
|
}
|
|
1702
1702
|
]
|
|
1703
1703
|
}
|
|
1704
|
-
]
|
|
1705
|
-
|
|
1706
|
-
{
|
|
1707
|
-
selling_plans: [
|
|
1704
|
+
],
|
|
1705
|
+
selling_plan_groups: [
|
|
1708
1706
|
{
|
|
1709
|
-
|
|
1710
|
-
options: [
|
|
1707
|
+
selling_plans: [
|
|
1711
1708
|
{
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
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
|
+
]
|
|
1715
1722
|
},
|
|
1716
1723
|
{
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
{
|
|
1724
|
-
id: 'yum selling plan id prepaid 6 shipments',
|
|
1725
|
-
options: [
|
|
1726
|
-
{
|
|
1727
|
-
name: 'Delivery every',
|
|
1728
|
-
position: 1,
|
|
1729
|
-
value: 'PREPAID-1 month'
|
|
1724
|
+
id: 'yum selling plan id 2',
|
|
1725
|
+
options: [
|
|
1726
|
+
{
|
|
1727
|
+
value: '1 week'
|
|
1728
|
+
}
|
|
1729
|
+
]
|
|
1730
1730
|
},
|
|
1731
1731
|
{
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1732
|
+
id: 'yum selling plan id 3',
|
|
1733
|
+
options: [
|
|
1734
|
+
{
|
|
1735
|
+
value: '1 month'
|
|
1736
|
+
}
|
|
1737
|
+
]
|
|
1735
1738
|
}
|
|
1736
1739
|
]
|
|
1737
1740
|
},
|
|
1738
1741
|
{
|
|
1739
|
-
|
|
1740
|
-
|
|
1742
|
+
selling_plans: [
|
|
1743
|
+
{
|
|
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
|
+
]
|
|
1757
|
+
},
|
|
1741
1758
|
{
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
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
|
+
]
|
|
1745
1772
|
},
|
|
1746
1773
|
{
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
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
|
+
]
|
|
1750
1787
|
}
|
|
1751
1788
|
]
|
|
1752
1789
|
}
|
|
1753
1790
|
]
|
|
1754
1791
|
}
|
|
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
|
-
}
|
|
1810
1792
|
}
|
|
1811
|
-
|
|
1812
|
-
|
|
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());
|
|
1793
|
+
}
|
|
1794
|
+
);
|
|
1914
1795
|
|
|
1915
1796
|
expect(actual).toEqual({
|
|
1916
1797
|
'yum product id': [
|
|
@@ -1928,126 +1809,203 @@ describe('productPlans', () => {
|
|
|
1928
1809
|
'yum variant id 1': [
|
|
1929
1810
|
{
|
|
1930
1811
|
frequency: 'yum selling plan id 2',
|
|
1931
|
-
regularPrice: '
|
|
1932
|
-
subscriptionPrice: '
|
|
1933
|
-
discountRate: '
|
|
1812
|
+
regularPrice: '$.50',
|
|
1813
|
+
subscriptionPrice: '$.25',
|
|
1814
|
+
discountRate: '$.25',
|
|
1934
1815
|
prepaidShipments: null
|
|
1935
1816
|
},
|
|
1936
1817
|
{
|
|
1937
1818
|
frequency: 'yum selling plan id prepaid 3 shipments',
|
|
1938
|
-
regularPrice: '
|
|
1939
|
-
subscriptionPrice: '
|
|
1819
|
+
regularPrice: '$.50',
|
|
1820
|
+
subscriptionPrice: '$.40',
|
|
1940
1821
|
discountRate: '20%',
|
|
1941
1822
|
prepaidShipments: 3,
|
|
1942
1823
|
regularPrepaidPrice: '$1.20',
|
|
1943
|
-
prepaidSavingsPerShipment: '
|
|
1944
|
-
prepaidSavingsTotal: '
|
|
1824
|
+
prepaidSavingsPerShipment: '$.10',
|
|
1825
|
+
prepaidSavingsTotal: '$.30'
|
|
1945
1826
|
},
|
|
1946
1827
|
{
|
|
1947
1828
|
frequency: 'yum selling plan id prepaid 6 shipments',
|
|
1948
|
-
regularPrice: '
|
|
1949
|
-
subscriptionPrice: '
|
|
1829
|
+
regularPrice: '$.50',
|
|
1830
|
+
subscriptionPrice: '$.40',
|
|
1950
1831
|
discountRate: '20%',
|
|
1951
1832
|
prepaidShipments: 6,
|
|
1952
1833
|
regularPrepaidPrice: '$2.40',
|
|
1953
|
-
prepaidSavingsPerShipment: '
|
|
1954
|
-
prepaidSavingsTotal: '
|
|
1834
|
+
prepaidSavingsPerShipment: '$.10',
|
|
1835
|
+
prepaidSavingsTotal: '$.60'
|
|
1955
1836
|
},
|
|
1956
1837
|
{
|
|
1957
1838
|
frequency: 'yum selling plan id prepaid 12 shipments',
|
|
1958
|
-
regularPrice: '
|
|
1959
|
-
subscriptionPrice: '
|
|
1839
|
+
regularPrice: '$.50',
|
|
1840
|
+
subscriptionPrice: '$.40',
|
|
1960
1841
|
discountRate: '20%',
|
|
1961
1842
|
prepaidShipments: 12,
|
|
1962
1843
|
regularPrepaidPrice: '$4.80',
|
|
1963
|
-
prepaidSavingsPerShipment: '
|
|
1844
|
+
prepaidSavingsPerShipment: '$.10',
|
|
1964
1845
|
prepaidSavingsTotal: '$1.20'
|
|
1965
1846
|
}
|
|
1966
1847
|
],
|
|
1967
1848
|
'yum variant id 2': [
|
|
1968
1849
|
{
|
|
1969
1850
|
frequency: 'yum selling plan id 3',
|
|
1970
|
-
regularPrice: '
|
|
1971
|
-
subscriptionPrice: '$
|
|
1972
|
-
discountRate: '$
|
|
1851
|
+
regularPrice: '$.10',
|
|
1852
|
+
subscriptionPrice: '$8',
|
|
1853
|
+
discountRate: '$2',
|
|
1973
1854
|
prepaidShipments: null
|
|
1974
1855
|
}
|
|
1975
1856
|
]
|
|
1976
1857
|
});
|
|
1977
1858
|
});
|
|
1978
1859
|
|
|
1979
|
-
it('should
|
|
1980
|
-
const actual = productPlans(
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
{
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
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
|
+
]
|
|
2008
1912
|
}
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
});
|
|
2012
|
-
|
|
2013
|
-
it('should return product plans with formatted discounts given action SETUP_CART', () => {
|
|
2014
|
-
const actual = productPlans({}, getSetupCartActionForRegularProduct());
|
|
1913
|
+
}
|
|
1914
|
+
);
|
|
2015
1915
|
|
|
2016
1916
|
expect(actual).toEqual({
|
|
2017
1917
|
'yum variant key 1': [
|
|
2018
1918
|
{
|
|
2019
1919
|
frequency: 'yum selling plan id 2',
|
|
2020
1920
|
prepaidShipments: null,
|
|
2021
|
-
regularPrice: '
|
|
2022
|
-
subscriptionPrice: '
|
|
2023
|
-
discountRate: '
|
|
1921
|
+
regularPrice: '$.50',
|
|
1922
|
+
subscriptionPrice: '$.25',
|
|
1923
|
+
discountRate: '$.25'
|
|
2024
1924
|
}
|
|
2025
1925
|
],
|
|
2026
1926
|
'yum variant key 2': [
|
|
2027
1927
|
{
|
|
2028
1928
|
frequency: 'yum selling plan id 3',
|
|
2029
1929
|
prepaidShipments: null,
|
|
2030
|
-
regularPrice: '
|
|
2031
|
-
subscriptionPrice: '$
|
|
2032
|
-
discountRate: '$
|
|
1930
|
+
regularPrice: '$.10',
|
|
1931
|
+
subscriptionPrice: '$8',
|
|
1932
|
+
discountRate: '$2'
|
|
2033
1933
|
}
|
|
2034
1934
|
]
|
|
2035
1935
|
});
|
|
2036
1936
|
});
|
|
2037
1937
|
|
|
2038
|
-
it('should
|
|
2039
|
-
const actual = productPlans(
|
|
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
|
+
);
|
|
2040
1998
|
|
|
2041
1999
|
expect(actual).toEqual({
|
|
2042
2000
|
'yum variant key 1': [
|
|
2043
2001
|
{
|
|
2044
2002
|
frequency: 'yum prepaid selling plan id',
|
|
2045
|
-
regularPrice: '
|
|
2046
|
-
subscriptionPrice: '
|
|
2003
|
+
regularPrice: '$.50',
|
|
2004
|
+
subscriptionPrice: '$.40',
|
|
2047
2005
|
discountRate: '20%',
|
|
2048
2006
|
prepaidShipments: 12,
|
|
2049
2007
|
regularPrepaidPrice: '$4.80',
|
|
2050
|
-
prepaidSavingsPerShipment: '
|
|
2008
|
+
prepaidSavingsPerShipment: '$.10',
|
|
2051
2009
|
prepaidSavingsTotal: '$1.20'
|
|
2052
2010
|
}
|
|
2053
2011
|
],
|
|
@@ -2055,34 +2013,9 @@ describe('productPlans', () => {
|
|
|
2055
2013
|
{
|
|
2056
2014
|
frequency: 'yum selling plan id 3',
|
|
2057
2015
|
prepaidShipments: null,
|
|
2058
|
-
regularPrice: '
|
|
2059
|
-
subscriptionPrice: '$
|
|
2060
|
-
discountRate: '$
|
|
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'
|
|
2016
|
+
regularPrice: '$.10',
|
|
2017
|
+
subscriptionPrice: '$8',
|
|
2018
|
+
discountRate: '$2'
|
|
2086
2019
|
}
|
|
2087
2020
|
]
|
|
2088
2021
|
});
|