@ordergroove/offers 2.30.2-alpha-PR-715-3.3 → 2.30.2
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 +11 -0
- package/dist/bundle-report.html +3 -3
- package/dist/offers.js +1 -1
- package/dist/offers.js.map +2 -2
- package/package.json +2 -2
- package/src/components/Price.js +1 -1
- package/src/components/__tests__/Price.spec.js +69 -0
- package/src/shopify/__tests__/productPlan.spec.js +44 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ordergroove/offers",
|
|
3
|
-
"version": "2.30.2
|
|
3
|
+
"version": "2.30.2",
|
|
4
4
|
"description": "offer state component",
|
|
5
5
|
"author": "Eugenio Lattanzio <eugenio63@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/ordergroove/plush-toys#readme",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@ordergroove/offers-templates": "^0.5.1"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "81e7eb5ad4aabc79a35df89c936632c8f422d7d5"
|
|
51
51
|
}
|
package/src/components/Price.js
CHANGED
|
@@ -25,7 +25,7 @@ export class Price extends withProduct(TemplateElement) {
|
|
|
25
25
|
const plans = this.productPlans[realProductId] || [];
|
|
26
26
|
|
|
27
27
|
if (this.payAsYouGo) {
|
|
28
|
-
const payAsYouGoPlan = plans.find(plan => plan.prepaidShipments === null);
|
|
28
|
+
const payAsYouGoPlan = plans.find(plan => plan.prepaidShipments === null || plan.prepaidShipments === undefined);
|
|
29
29
|
if (!payAsYouGoPlan) return '';
|
|
30
30
|
return payAsYouGoPlan.subscriptionPrice;
|
|
31
31
|
}
|
|
@@ -72,6 +72,75 @@ describe('Price', () => {
|
|
|
72
72
|
expect(insideText).toBe('10%');
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
+
it('should render payAsYouGo price with undefined prepaidShipments', async () => {
|
|
76
|
+
const template = html`
|
|
77
|
+
<og-some-price pay-as-you-go product="yum id"> </og-some-price>
|
|
78
|
+
`;
|
|
79
|
+
const priceDivUndefinedPrepaid = await renderPriceTemplate(template, {
|
|
80
|
+
frequency: '1_3',
|
|
81
|
+
productPlans: {
|
|
82
|
+
'yum id': [
|
|
83
|
+
{
|
|
84
|
+
frequency: '1_3',
|
|
85
|
+
regularPrice: '$1.00',
|
|
86
|
+
discountRate: '10%',
|
|
87
|
+
subscriptionPrice: '$1.00',
|
|
88
|
+
prepaidShipments: 3
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
frequency: '1_3',
|
|
92
|
+
regularPrice: '$1.00',
|
|
93
|
+
discountRate: '10%',
|
|
94
|
+
subscriptionPrice: '$2.00'
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
frequency: '1_3',
|
|
98
|
+
regularPrice: '$1.00',
|
|
99
|
+
discountRate: '10%',
|
|
100
|
+
subscriptionPrice: '$1.00',
|
|
101
|
+
prepaidShipments: 6
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('should render payAsYouGo price with nullish prepaidShipments', async () => {
|
|
109
|
+
const template = html`
|
|
110
|
+
<og-some-price pay-as-you-go product="yum id"> </og-some-price>
|
|
111
|
+
`;
|
|
112
|
+
const priceDivNullPrepaid = await renderPriceTemplate(template, {
|
|
113
|
+
frequency: '1_3',
|
|
114
|
+
productPlans: {
|
|
115
|
+
'yum id': [
|
|
116
|
+
{
|
|
117
|
+
frequency: '1_3',
|
|
118
|
+
regularPrice: '$1.00',
|
|
119
|
+
discountRate: '10%',
|
|
120
|
+
subscriptionPrice: '$1.00',
|
|
121
|
+
prepaidShipments: 3
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
frequency: '1_3',
|
|
125
|
+
regularPrice: '$1.00',
|
|
126
|
+
discountRate: '10%',
|
|
127
|
+
subscriptionPrice: '$4.50',
|
|
128
|
+
prepaidShipments: null
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
frequency: '1_3',
|
|
132
|
+
regularPrice: '$1.00',
|
|
133
|
+
discountRate: '10%',
|
|
134
|
+
subscriptionPrice: '$1.00',
|
|
135
|
+
prepaidShipments: 6
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
const ogPriceNullPrepaid = priceDivNullPrepaid.shadowRoot.innerHTML;
|
|
141
|
+
expect(ogPriceNullPrepaid).toContain('$4.50');
|
|
142
|
+
});
|
|
143
|
+
|
|
75
144
|
it('should render empty price when subscription is equal to regular', async () => {
|
|
76
145
|
const template = html`
|
|
77
146
|
<og-some-price discount product="yum id"> </og-some-price>
|
|
@@ -236,6 +236,50 @@ describe('Shopify productPlan Reducer', () => {
|
|
|
236
236
|
|
|
237
237
|
expect(newProductPlan).toEqual(expectedProductPlan);
|
|
238
238
|
});
|
|
239
|
+
|
|
240
|
+
it('should deal with dividing integers and not add decimals to prices/discounts that are added', () => {
|
|
241
|
+
const allocation = {
|
|
242
|
+
price: 4798,
|
|
243
|
+
compare_at_price: 1999,
|
|
244
|
+
selling_plan: {
|
|
245
|
+
options: [
|
|
246
|
+
{
|
|
247
|
+
name: 'Delivery every',
|
|
248
|
+
position: 1,
|
|
249
|
+
value: 'PREPAID-1 month'
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
name: 'Shipment amount',
|
|
253
|
+
position: 2,
|
|
254
|
+
value: '3 shipments'
|
|
255
|
+
}
|
|
256
|
+
]
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
const productPlan = {
|
|
261
|
+
frequency: '688412852500',
|
|
262
|
+
regularPrice: '19.99',
|
|
263
|
+
subscriptionPrice: '$15.99',
|
|
264
|
+
discountRate: '20%',
|
|
265
|
+
prepaidShipments: 3
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
const expectedProductPlan = {
|
|
269
|
+
frequency: '688412852500',
|
|
270
|
+
regularPrice: '19.99',
|
|
271
|
+
subscriptionPrice: '$15.99',
|
|
272
|
+
discountRate: '20%',
|
|
273
|
+
prepaidShipments: 3,
|
|
274
|
+
regularPrepaidPrice: '$47.98',
|
|
275
|
+
prepaidSavingsPerShipment: '$4.00',
|
|
276
|
+
prepaidSavingsTotal: '$11.99'
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const newProductPlan = addPrepaidPriceAndSavings(allocation, productPlan);
|
|
280
|
+
|
|
281
|
+
expect(newProductPlan).toEqual(expectedProductPlan);
|
|
282
|
+
});
|
|
239
283
|
});
|
|
240
284
|
|
|
241
285
|
describe('mapSellingPlanToDiscount', () => {
|