@ordergroove/offers 2.44.0 → 2.44.1-alpha-PR-1167-2.36
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/dist/bundle-report.html +42 -39
- package/dist/offers.js +69 -69
- package/dist/offers.js.map +4 -4
- package/package.json +2 -2
- package/src/components/FrequencyStatus.js +14 -10
- package/src/components/Offer.js +33 -14
- package/src/components/OptinButton.js +2 -2
- package/src/components/OptinSelect.js +6 -5
- package/src/components/OptinStatus.js +16 -9
- package/src/components/Price.js +3 -3
- package/src/components/SelectFrequency.js +11 -6
- package/src/components/TestWizard.js +45 -41
- package/src/components/UpsellModal.js +9 -3
- package/src/components/__tests__/Offer.spec.js +0 -19
- package/src/components/__tests__/OptinStatus.spec.js +17 -4
- package/src/core/__tests__/actions.spec.js +47 -1
- package/src/core/__tests__/base.spec.js +0 -77
- package/src/core/__tests__/experiments.spec.js +0 -3
- package/src/core/__tests__/offerRequest.spec.js +2 -1
- package/src/core/__tests__/selectors.spec.js +7 -7
- package/src/core/actions-preview.js +6 -3
- package/src/core/actions.js +22 -13
- package/src/core/base.js +0 -23
- package/src/core/offerRequest.js +1 -1
- package/src/core/{reducer.js → reducer.ts} +30 -10
- package/src/core/selectors.ts +215 -0
- package/src/core/types/api.ts +71 -0
- package/src/core/types/reducer.ts +94 -0
- package/src/core/types/utility.ts +1 -0
- package/src/core/utils.ts +32 -15
- package/src/make-api.js +1 -1
- package/src/shopify/__tests__/reducers/config.spec.js +603 -0
- package/src/shopify/__tests__/shopifyReducer.spec.js +69 -744
- package/src/shopify/__tests__/utils.spec.js +24 -1
- package/src/shopify/reducers/config.ts +185 -0
- package/src/shopify/shopifyMiddleware.ts +2 -9
- package/src/shopify/{shopifyReducer.js → shopifyReducer.ts} +50 -195
- package/src/shopify/utils.ts +25 -0
- package/src/core/selectors.js +0 -192
- package/src/types.ts +0 -16
|
@@ -1,32 +1,9 @@
|
|
|
1
1
|
import * as constants from '../../core/constants';
|
|
2
|
-
import {
|
|
3
|
-
autoshipEligible,
|
|
4
|
-
config,
|
|
5
|
-
inStock,
|
|
6
|
-
offer,
|
|
7
|
-
optedin,
|
|
8
|
-
productOffer,
|
|
9
|
-
productPlans,
|
|
10
|
-
textToFreq
|
|
11
|
-
} from '../shopifyReducer';
|
|
2
|
+
import { autoshipEligible, inStock, offer, optedin, productOffer, productPlans } from '../shopifyReducer';
|
|
12
3
|
import { getObjectStructuredProductPlans } from '../../core/adapters';
|
|
13
4
|
import { DEFAULT_PAY_AS_YOU_GO_GROUP_NAME } from '../utils';
|
|
14
5
|
|
|
15
6
|
describe('autoshipEligible', () => {
|
|
16
|
-
it('should return true for each id given action RECEIVE_PRODUCT_PLANS', () => {
|
|
17
|
-
const actual = autoshipEligible(
|
|
18
|
-
{},
|
|
19
|
-
{
|
|
20
|
-
type: constants.RECEIVE_PRODUCT_PLANS,
|
|
21
|
-
payload: {
|
|
22
|
-
'yum product id 1': {},
|
|
23
|
-
'yum product id 2': {}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
);
|
|
27
|
-
expect(actual).toEqual({ 'yum product id 1': true, 'yum product id 2': true });
|
|
28
|
-
});
|
|
29
|
-
|
|
30
7
|
it('should return null for each key in items given action SETUP_CART', () => {
|
|
31
8
|
const actual = autoshipEligible(
|
|
32
9
|
{},
|
|
@@ -53,7 +30,7 @@ describe('autoshipEligible', () => {
|
|
|
53
30
|
prepaid2: 3,
|
|
54
31
|
psfl: 4
|
|
55
32
|
};
|
|
56
|
-
function getSetupProductPayload({
|
|
33
|
+
function getSetupProductPayload({ variants = {}, additionalSellingPlanGroups = {} } = {}) {
|
|
57
34
|
const sellingPlanGroups = {
|
|
58
35
|
'Subscribe and Save': [sellingPlans.default],
|
|
59
36
|
...additionalSellingPlanGroups
|
|
@@ -61,7 +38,6 @@ describe('autoshipEligible', () => {
|
|
|
61
38
|
return {
|
|
62
39
|
product: {
|
|
63
40
|
id: 'yum product id',
|
|
64
|
-
selling_plan_allocations: productSellingPlans?.map(id => ({ selling_plan_id: id })),
|
|
65
41
|
variants: Object.entries(variants).map(([productId, sellingPlanIds]) => ({
|
|
66
42
|
id: productId,
|
|
67
43
|
selling_plan_allocations: sellingPlanIds.map(id => ({ selling_plan_id: id }))
|
|
@@ -80,7 +56,6 @@ describe('autoshipEligible', () => {
|
|
|
80
56
|
{
|
|
81
57
|
type: constants.SETUP_PRODUCT,
|
|
82
58
|
payload: getSetupProductPayload({
|
|
83
|
-
productSellingPlans: [sellingPlans.default],
|
|
84
59
|
variants: {
|
|
85
60
|
'yum variant id': [sellingPlans.default]
|
|
86
61
|
}
|
|
@@ -88,10 +63,10 @@ describe('autoshipEligible', () => {
|
|
|
88
63
|
}
|
|
89
64
|
);
|
|
90
65
|
|
|
91
|
-
expect(actual).toEqual({ 'yum
|
|
66
|
+
expect(actual).toEqual({ 'yum variant id': true });
|
|
92
67
|
});
|
|
93
68
|
|
|
94
|
-
it('should return false for each
|
|
69
|
+
it('should return false for each variant given action SETUP_PRODUCT and products have no selling plan allocations', () => {
|
|
95
70
|
const actual = autoshipEligible(
|
|
96
71
|
{},
|
|
97
72
|
{
|
|
@@ -104,7 +79,7 @@ describe('autoshipEligible', () => {
|
|
|
104
79
|
}
|
|
105
80
|
);
|
|
106
81
|
|
|
107
|
-
expect(actual).toEqual({ 'yum
|
|
82
|
+
expect(actual).toEqual({ 'yum variant id': false });
|
|
108
83
|
});
|
|
109
84
|
|
|
110
85
|
it('should return unmodified state given unsupported action', () => {
|
|
@@ -139,7 +114,6 @@ describe('autoshipEligible', () => {
|
|
|
139
114
|
);
|
|
140
115
|
|
|
141
116
|
expect(actual).toEqual({
|
|
142
|
-
'yum product id': false,
|
|
143
117
|
'single-non-prepaid': true,
|
|
144
118
|
'prepaid-and-non-prepaid': true,
|
|
145
119
|
'single-prepaid': false,
|
|
@@ -166,7 +140,6 @@ describe('autoshipEligible', () => {
|
|
|
166
140
|
);
|
|
167
141
|
|
|
168
142
|
expect(actual).toEqual({
|
|
169
|
-
'yum product id': false,
|
|
170
143
|
'single-non-psfl': true,
|
|
171
144
|
'default-sub-psfl': true,
|
|
172
145
|
'not-default-sub-psfl': true
|
|
@@ -174,506 +147,7 @@ describe('autoshipEligible', () => {
|
|
|
174
147
|
});
|
|
175
148
|
});
|
|
176
149
|
|
|
177
|
-
describe('config', () => {
|
|
178
|
-
it('should return unique frequencies given action RECEIVE_PRODUCT_PLANS', () => {
|
|
179
|
-
const actual = config(
|
|
180
|
-
{},
|
|
181
|
-
{
|
|
182
|
-
type: constants.RECEIVE_PRODUCT_PLANS,
|
|
183
|
-
payload: {
|
|
184
|
-
'product plan id': { '1_1': {}, '3_1': {} }
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
expect(actual).toEqual(
|
|
190
|
-
jasmine.objectContaining({
|
|
191
|
-
frequencies: ['1_1', '3_1']
|
|
192
|
-
})
|
|
193
|
-
);
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
it('should set defaultFrequency to selling plan given selling plan exists for frequency given action SETUP_PRODUCT', () => {
|
|
197
|
-
const actual = config(
|
|
198
|
-
{
|
|
199
|
-
defaultFrequency: '1_2'
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
type: constants.SETUP_PRODUCT,
|
|
203
|
-
payload: {
|
|
204
|
-
offer: {
|
|
205
|
-
config: {
|
|
206
|
-
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
207
|
-
frequenciesEveryPeriod: ['1_1', '1_2']
|
|
208
|
-
}
|
|
209
|
-
},
|
|
210
|
-
product: {
|
|
211
|
-
selling_plan_groups: [
|
|
212
|
-
{
|
|
213
|
-
name: DEFAULT_PAY_AS_YOU_GO_GROUP_NAME,
|
|
214
|
-
selling_plans: [
|
|
215
|
-
{
|
|
216
|
-
id: 'yum selling plan id 1',
|
|
217
|
-
options: [
|
|
218
|
-
{
|
|
219
|
-
value: '1 day'
|
|
220
|
-
}
|
|
221
|
-
]
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
id: 'yum selling plan id 2',
|
|
225
|
-
options: [
|
|
226
|
-
{
|
|
227
|
-
value: '1 week'
|
|
228
|
-
}
|
|
229
|
-
]
|
|
230
|
-
}
|
|
231
|
-
]
|
|
232
|
-
}
|
|
233
|
-
]
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
);
|
|
238
|
-
|
|
239
|
-
expect(actual).toEqual(
|
|
240
|
-
jasmine.objectContaining({
|
|
241
|
-
defaultFrequency: 'yum selling plan id 2'
|
|
242
|
-
})
|
|
243
|
-
);
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
it('should set defaultFrequency to first selling plan given selling plan does not exist for frequency given action SETUP_PRODUCT', () => {
|
|
247
|
-
const actual = config(
|
|
248
|
-
{
|
|
249
|
-
defaultFrequency: '1_3'
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
type: constants.SETUP_PRODUCT,
|
|
253
|
-
payload: {
|
|
254
|
-
offer: {
|
|
255
|
-
config: {
|
|
256
|
-
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
257
|
-
frequenciesEveryPeriod: ['1_1', '1_2']
|
|
258
|
-
}
|
|
259
|
-
},
|
|
260
|
-
product: {
|
|
261
|
-
selling_plan_groups: [
|
|
262
|
-
{
|
|
263
|
-
name: DEFAULT_PAY_AS_YOU_GO_GROUP_NAME,
|
|
264
|
-
selling_plans: [
|
|
265
|
-
{
|
|
266
|
-
id: 'yum selling plan id 1',
|
|
267
|
-
options: [
|
|
268
|
-
{
|
|
269
|
-
value: '1 day'
|
|
270
|
-
}
|
|
271
|
-
]
|
|
272
|
-
},
|
|
273
|
-
{
|
|
274
|
-
id: 'yum selling plan id 2',
|
|
275
|
-
options: [
|
|
276
|
-
{
|
|
277
|
-
value: '1 week'
|
|
278
|
-
}
|
|
279
|
-
]
|
|
280
|
-
}
|
|
281
|
-
]
|
|
282
|
-
}
|
|
283
|
-
]
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
);
|
|
288
|
-
|
|
289
|
-
expect(actual).toEqual(
|
|
290
|
-
jasmine.objectContaining({
|
|
291
|
-
defaultFrequency: 'yum selling plan id 1'
|
|
292
|
-
})
|
|
293
|
-
);
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
it('should not change default frequency if is already a selling plan given action SETUP_PRODUCT', () => {
|
|
297
|
-
const actual = config(
|
|
298
|
-
{
|
|
299
|
-
defaultFrequency: 'yum selling plan id 5'
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
type: constants.SETUP_PRODUCT,
|
|
303
|
-
payload: {
|
|
304
|
-
offer: {
|
|
305
|
-
config: {
|
|
306
|
-
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
307
|
-
frequenciesEveryPeriod: ['1_1', '1_2']
|
|
308
|
-
}
|
|
309
|
-
},
|
|
310
|
-
product: {
|
|
311
|
-
selling_plan_groups: [
|
|
312
|
-
{
|
|
313
|
-
name: DEFAULT_PAY_AS_YOU_GO_GROUP_NAME,
|
|
314
|
-
selling_plans: [
|
|
315
|
-
{
|
|
316
|
-
id: 'yum selling plan id 1',
|
|
317
|
-
options: [
|
|
318
|
-
{
|
|
319
|
-
value: '1 day'
|
|
320
|
-
}
|
|
321
|
-
]
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
id: 'yum selling plan id 2',
|
|
325
|
-
options: [
|
|
326
|
-
{
|
|
327
|
-
value: '1 week'
|
|
328
|
-
}
|
|
329
|
-
]
|
|
330
|
-
}
|
|
331
|
-
]
|
|
332
|
-
}
|
|
333
|
-
]
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
);
|
|
338
|
-
|
|
339
|
-
expect(actual).toEqual(
|
|
340
|
-
jasmine.objectContaining({
|
|
341
|
-
defaultFrequency: 'yum selling plan id 5'
|
|
342
|
-
})
|
|
343
|
-
);
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
const defaultSellingPlanPayload = {
|
|
347
|
-
product: {
|
|
348
|
-
selling_plan_groups: [
|
|
349
|
-
{
|
|
350
|
-
name: DEFAULT_PAY_AS_YOU_GO_GROUP_NAME,
|
|
351
|
-
selling_plans: [
|
|
352
|
-
{
|
|
353
|
-
id: 'yum selling plan id 1'
|
|
354
|
-
},
|
|
355
|
-
{
|
|
356
|
-
id: 'yum selling plan id 2'
|
|
357
|
-
}
|
|
358
|
-
]
|
|
359
|
-
}
|
|
360
|
-
]
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
it('should return selling plan ids as frequencies given action SETUP_PRODUCT', () => {
|
|
365
|
-
const actual = config(
|
|
366
|
-
{},
|
|
367
|
-
{
|
|
368
|
-
type: constants.SETUP_PRODUCT,
|
|
369
|
-
payload: defaultSellingPlanPayload
|
|
370
|
-
}
|
|
371
|
-
);
|
|
372
|
-
|
|
373
|
-
expect(actual).toEqual(
|
|
374
|
-
jasmine.objectContaining({
|
|
375
|
-
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
376
|
-
hasProductSpecificFrequencies: false
|
|
377
|
-
})
|
|
378
|
-
);
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
it('should return values of first OG selling plan group as frequencies text given action SETUP_PRODUCT', () => {
|
|
382
|
-
const actual = config(
|
|
383
|
-
{},
|
|
384
|
-
{
|
|
385
|
-
type: constants.SETUP_PRODUCT,
|
|
386
|
-
payload: {
|
|
387
|
-
product: {
|
|
388
|
-
selling_plan_groups: [
|
|
389
|
-
{
|
|
390
|
-
name: 'Old Selling Plan Group',
|
|
391
|
-
options: [{ values: 'old yum values' }],
|
|
392
|
-
selling_plans: [
|
|
393
|
-
{
|
|
394
|
-
id: 'old yum selling plan id'
|
|
395
|
-
}
|
|
396
|
-
]
|
|
397
|
-
},
|
|
398
|
-
{
|
|
399
|
-
name: DEFAULT_PAY_AS_YOU_GO_GROUP_NAME,
|
|
400
|
-
options: [{ values: 'yum values' }],
|
|
401
|
-
selling_plans: [
|
|
402
|
-
{
|
|
403
|
-
id: 'yum selling plan id'
|
|
404
|
-
}
|
|
405
|
-
]
|
|
406
|
-
}
|
|
407
|
-
]
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
);
|
|
412
|
-
|
|
413
|
-
expect(actual).toEqual(
|
|
414
|
-
jasmine.objectContaining({
|
|
415
|
-
frequenciesText: 'yum values'
|
|
416
|
-
})
|
|
417
|
-
);
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
it('should use product-specific frequency selling plan groups if present', () => {
|
|
421
|
-
const actual = config(
|
|
422
|
-
{},
|
|
423
|
-
{
|
|
424
|
-
type: constants.SETUP_PRODUCT,
|
|
425
|
-
payload: {
|
|
426
|
-
product: {
|
|
427
|
-
selling_plan_groups: [
|
|
428
|
-
{
|
|
429
|
-
name: 'og_psfl_2m4m6m',
|
|
430
|
-
options: [
|
|
431
|
-
{
|
|
432
|
-
values: ['2 months', '4 months', '6 months']
|
|
433
|
-
}
|
|
434
|
-
],
|
|
435
|
-
selling_plans: [
|
|
436
|
-
{
|
|
437
|
-
id: 'psfl-id-1'
|
|
438
|
-
},
|
|
439
|
-
{
|
|
440
|
-
id: 'psfl-id-2'
|
|
441
|
-
},
|
|
442
|
-
{
|
|
443
|
-
id: 'psfl-id-3'
|
|
444
|
-
}
|
|
445
|
-
]
|
|
446
|
-
},
|
|
447
|
-
{
|
|
448
|
-
name: 'Subscribe and Save',
|
|
449
|
-
options: [
|
|
450
|
-
{
|
|
451
|
-
values: ['month', '2 months', '3 months']
|
|
452
|
-
}
|
|
453
|
-
],
|
|
454
|
-
selling_plans: [
|
|
455
|
-
{
|
|
456
|
-
id: 'regular-id-1'
|
|
457
|
-
},
|
|
458
|
-
{
|
|
459
|
-
id: 'regular-id-2'
|
|
460
|
-
},
|
|
461
|
-
{
|
|
462
|
-
id: 'regular-id-3'
|
|
463
|
-
}
|
|
464
|
-
]
|
|
465
|
-
}
|
|
466
|
-
]
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
);
|
|
471
|
-
|
|
472
|
-
expect(actual).toEqual(
|
|
473
|
-
jasmine.objectContaining({
|
|
474
|
-
frequencies: ['psfl-id-1', 'psfl-id-2', 'psfl-id-3'],
|
|
475
|
-
hasProductSpecificFrequencies: true
|
|
476
|
-
})
|
|
477
|
-
);
|
|
478
|
-
});
|
|
479
|
-
|
|
480
|
-
it('does not overwrite hasProductSpecificFrequencies on subsequent calls', () => {
|
|
481
|
-
const actual = config(
|
|
482
|
-
{
|
|
483
|
-
hasProductSpecificFrequencies: true
|
|
484
|
-
},
|
|
485
|
-
{
|
|
486
|
-
type: constants.SETUP_PRODUCT,
|
|
487
|
-
payload: defaultSellingPlanPayload
|
|
488
|
-
}
|
|
489
|
-
);
|
|
490
|
-
|
|
491
|
-
expect(actual).toEqual(
|
|
492
|
-
jasmine.objectContaining({
|
|
493
|
-
hasProductSpecificFrequencies: true
|
|
494
|
-
})
|
|
495
|
-
);
|
|
496
|
-
});
|
|
497
|
-
|
|
498
|
-
it('should set prepaidSellingPlans', () => {
|
|
499
|
-
const sellingPlanGroups = [
|
|
500
|
-
{
|
|
501
|
-
name: 'Prepaid-43017264201944',
|
|
502
|
-
selling_plans: [
|
|
503
|
-
{
|
|
504
|
-
id: 2146042072,
|
|
505
|
-
name: 'Delivered every 2 months, prepaid for 4 shipments',
|
|
506
|
-
options: [
|
|
507
|
-
{ name: 'Delivery every', position: 1, value: 'PREPAID-2 months' },
|
|
508
|
-
{ name: 'Shipment amount', position: 2, value: '4 shipments' }
|
|
509
|
-
]
|
|
510
|
-
}
|
|
511
|
-
]
|
|
512
|
-
}
|
|
513
|
-
];
|
|
514
|
-
const actual = config(
|
|
515
|
-
{},
|
|
516
|
-
{
|
|
517
|
-
type: constants.SETUP_PRODUCT,
|
|
518
|
-
payload: {
|
|
519
|
-
product: {
|
|
520
|
-
selling_plan_groups: sellingPlanGroups
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
);
|
|
525
|
-
expect(actual).toEqual(
|
|
526
|
-
jasmine.objectContaining({
|
|
527
|
-
prepaidSellingPlans: {
|
|
528
|
-
43017264201944: [
|
|
529
|
-
{
|
|
530
|
-
numberShipments: 4,
|
|
531
|
-
sellingPlan: '2146042072'
|
|
532
|
-
}
|
|
533
|
-
]
|
|
534
|
-
}
|
|
535
|
-
})
|
|
536
|
-
);
|
|
537
|
-
});
|
|
538
|
-
|
|
539
|
-
it('should add prepaidSellingPlans on top of old ones', () => {
|
|
540
|
-
const sellingPlanGroups = [
|
|
541
|
-
{
|
|
542
|
-
name: 'Prepaid-43017264201946',
|
|
543
|
-
selling_plans: [
|
|
544
|
-
{
|
|
545
|
-
id: 2146042072,
|
|
546
|
-
name: 'Delivered every 1 months, prepaid for 3 shipments',
|
|
547
|
-
options: [
|
|
548
|
-
{ name: 'Delivery every', position: 1, value: 'PREPAID-1 months' },
|
|
549
|
-
{ name: 'Shipment amount', position: 2, value: '3 shipments' }
|
|
550
|
-
]
|
|
551
|
-
}
|
|
552
|
-
]
|
|
553
|
-
},
|
|
554
|
-
{
|
|
555
|
-
name: 'Prepaid-43017264201945',
|
|
556
|
-
selling_plans: [
|
|
557
|
-
{
|
|
558
|
-
id: 2146042073,
|
|
559
|
-
name: 'Delivered every 3 months, prepaid for 5 shipments',
|
|
560
|
-
options: [
|
|
561
|
-
{ name: 'Delivery every', position: 1, value: 'PREPAID-3 months' },
|
|
562
|
-
{ name: 'Shipment amount', position: 2, value: '5 shipments' }
|
|
563
|
-
]
|
|
564
|
-
}
|
|
565
|
-
]
|
|
566
|
-
}
|
|
567
|
-
];
|
|
568
|
-
const actual = config(
|
|
569
|
-
{
|
|
570
|
-
prepaidSellingPlans: {
|
|
571
|
-
43017264201946: [
|
|
572
|
-
{
|
|
573
|
-
numberShipments: 1,
|
|
574
|
-
sellingPlan: '2146042072'
|
|
575
|
-
}
|
|
576
|
-
],
|
|
577
|
-
43017264201944: [
|
|
578
|
-
{
|
|
579
|
-
numberShipments: 4,
|
|
580
|
-
sellingPlan: '2146042071'
|
|
581
|
-
}
|
|
582
|
-
]
|
|
583
|
-
}
|
|
584
|
-
},
|
|
585
|
-
{
|
|
586
|
-
type: constants.SETUP_PRODUCT,
|
|
587
|
-
payload: {
|
|
588
|
-
product: {
|
|
589
|
-
selling_plan_groups: sellingPlanGroups
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
);
|
|
594
|
-
expect(actual).toEqual(
|
|
595
|
-
jasmine.objectContaining({
|
|
596
|
-
prepaidSellingPlans: {
|
|
597
|
-
43017264201944: [
|
|
598
|
-
{
|
|
599
|
-
numberShipments: 4,
|
|
600
|
-
sellingPlan: '2146042071'
|
|
601
|
-
}
|
|
602
|
-
],
|
|
603
|
-
43017264201946: [
|
|
604
|
-
{
|
|
605
|
-
numberShipments: 3,
|
|
606
|
-
sellingPlan: '2146042072'
|
|
607
|
-
}
|
|
608
|
-
],
|
|
609
|
-
43017264201945: [
|
|
610
|
-
{
|
|
611
|
-
numberShipments: 5,
|
|
612
|
-
sellingPlan: '2146042073'
|
|
613
|
-
}
|
|
614
|
-
]
|
|
615
|
-
}
|
|
616
|
-
})
|
|
617
|
-
);
|
|
618
|
-
});
|
|
619
|
-
|
|
620
|
-
it('should return unmodified state given unsupported action', () => {
|
|
621
|
-
const actual = config(
|
|
622
|
-
{ 'yum existing key': 'yum existing value' },
|
|
623
|
-
{
|
|
624
|
-
type: 'yum unsupported action',
|
|
625
|
-
payload: {}
|
|
626
|
-
}
|
|
627
|
-
);
|
|
628
|
-
|
|
629
|
-
expect(actual).toEqual({ 'yum existing key': 'yum existing value' });
|
|
630
|
-
});
|
|
631
|
-
|
|
632
|
-
it('should not set prepaid selling plan as a defaultFrequency', () => {
|
|
633
|
-
const actual = config(
|
|
634
|
-
{},
|
|
635
|
-
{
|
|
636
|
-
type: constants.RECEIVE_OFFER,
|
|
637
|
-
payload: {
|
|
638
|
-
offer: {
|
|
639
|
-
product: { id: 123 },
|
|
640
|
-
config: {
|
|
641
|
-
frequencies: ['yum selling plan id 1', 'yum selling plan id 4'],
|
|
642
|
-
frequenciesEveryPeriod: ['1_1', '1_4'],
|
|
643
|
-
prepaidSellingPlans: {
|
|
644
|
-
123: [
|
|
645
|
-
{
|
|
646
|
-
sellingPlan: 'prepaid selling plan'
|
|
647
|
-
}
|
|
648
|
-
]
|
|
649
|
-
}
|
|
650
|
-
},
|
|
651
|
-
defaultFrequency: 'prepaid selling plan'
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
);
|
|
656
|
-
expect(actual).toEqual({
|
|
657
|
-
defaultFrequency: 'yum selling plan id 1'
|
|
658
|
-
});
|
|
659
|
-
});
|
|
660
|
-
});
|
|
661
|
-
|
|
662
150
|
describe('inStock', () => {
|
|
663
|
-
it('should return true for each id given action RECEIVE_PRODUCT_PLANS', () => {
|
|
664
|
-
const actual = inStock(
|
|
665
|
-
{},
|
|
666
|
-
{
|
|
667
|
-
type: constants.RECEIVE_PRODUCT_PLANS,
|
|
668
|
-
payload: {
|
|
669
|
-
'yum product id 1': {},
|
|
670
|
-
'yum product id 2': {}
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
);
|
|
674
|
-
expect(actual).toEqual({ 'yum product id 1': true, 'yum product id 2': true });
|
|
675
|
-
});
|
|
676
|
-
|
|
677
151
|
it('should return null item key given action SETUP_CART', () => {
|
|
678
152
|
const actual = inStock(
|
|
679
153
|
{},
|
|
@@ -847,11 +321,10 @@ describe('optedin', () => {
|
|
|
847
321
|
{
|
|
848
322
|
type: constants.RECEIVE_OFFER,
|
|
849
323
|
payload: {
|
|
850
|
-
offer: {
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
}
|
|
324
|
+
offer: {},
|
|
325
|
+
frequencyConfig: {
|
|
326
|
+
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
327
|
+
frequenciesEveryPeriod: ['1_1', '1_2']
|
|
855
328
|
}
|
|
856
329
|
}
|
|
857
330
|
}
|
|
@@ -877,11 +350,11 @@ describe('optedin', () => {
|
|
|
877
350
|
type: constants.RECEIVE_OFFER,
|
|
878
351
|
payload: {
|
|
879
352
|
offer: {
|
|
880
|
-
config: {
|
|
881
|
-
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
882
|
-
frequenciesEveryPeriod: ['3_1', '3_2']
|
|
883
|
-
},
|
|
884
353
|
defaultFrequency: '3_2'
|
|
354
|
+
},
|
|
355
|
+
frequencyConfig: {
|
|
356
|
+
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
357
|
+
frequenciesEveryPeriod: ['3_1', '3_2']
|
|
885
358
|
}
|
|
886
359
|
}
|
|
887
360
|
}
|
|
@@ -906,11 +379,10 @@ describe('optedin', () => {
|
|
|
906
379
|
{
|
|
907
380
|
type: constants.RECEIVE_OFFER,
|
|
908
381
|
payload: {
|
|
909
|
-
offer: {
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
}
|
|
382
|
+
offer: {},
|
|
383
|
+
frequencyConfig: {
|
|
384
|
+
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
385
|
+
frequenciesEveryPeriod: ['3_1', '3_2']
|
|
914
386
|
}
|
|
915
387
|
}
|
|
916
388
|
}
|
|
@@ -936,11 +408,10 @@ describe('optedin', () => {
|
|
|
936
408
|
{
|
|
937
409
|
type: constants.RECEIVE_OFFER,
|
|
938
410
|
payload: {
|
|
939
|
-
offer: {
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
}
|
|
411
|
+
offer: {},
|
|
412
|
+
frequencyConfig: {
|
|
413
|
+
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
414
|
+
frequenciesEveryPeriod: ['1_1', '1_2']
|
|
944
415
|
}
|
|
945
416
|
}
|
|
946
417
|
}
|
|
@@ -979,11 +450,11 @@ describe('optedin', () => {
|
|
|
979
450
|
'yum product id 1': true
|
|
980
451
|
},
|
|
981
452
|
offer: {
|
|
982
|
-
config: {
|
|
983
|
-
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
984
|
-
frequenciesEveryPeriod: ['1_1', '1_2']
|
|
985
|
-
},
|
|
986
453
|
defaultFrequency: 'yum offer default frequency'
|
|
454
|
+
},
|
|
455
|
+
frequencyConfig: {
|
|
456
|
+
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
457
|
+
frequenciesEveryPeriod: ['1_1', '1_2']
|
|
987
458
|
}
|
|
988
459
|
}
|
|
989
460
|
});
|
|
@@ -1016,11 +487,11 @@ describe('optedin', () => {
|
|
|
1016
487
|
'yum product id 1': true
|
|
1017
488
|
},
|
|
1018
489
|
offer: {
|
|
1019
|
-
config: {
|
|
1020
|
-
frequencies: ['yum selling plan id 1'],
|
|
1021
|
-
frequenciesEveryPeriod: ['1_1']
|
|
1022
|
-
},
|
|
1023
490
|
defaultFrequency: 'yum offer default selling plan'
|
|
491
|
+
},
|
|
492
|
+
frequencyConfig: {
|
|
493
|
+
frequencies: ['yum selling plan id 1'],
|
|
494
|
+
frequenciesEveryPeriod: ['1_1']
|
|
1024
495
|
}
|
|
1025
496
|
}
|
|
1026
497
|
});
|
|
@@ -1052,11 +523,11 @@ describe('optedin', () => {
|
|
|
1052
523
|
'yum product id 1': true
|
|
1053
524
|
},
|
|
1054
525
|
offer: {
|
|
1055
|
-
config: {
|
|
1056
|
-
frequencies: ['yum selling plan id 1', 'yum selling plan id 3'],
|
|
1057
|
-
frequenciesEveryPeriod: ['1_1', '1_3']
|
|
1058
|
-
},
|
|
1059
526
|
defaultFrequency: '1_3'
|
|
527
|
+
},
|
|
528
|
+
frequencyConfig: {
|
|
529
|
+
frequencies: ['yum selling plan id 1', 'yum selling plan id 3'],
|
|
530
|
+
frequenciesEveryPeriod: ['1_1', '1_3']
|
|
1060
531
|
}
|
|
1061
532
|
}
|
|
1062
533
|
});
|
|
@@ -1088,11 +559,11 @@ describe('optedin', () => {
|
|
|
1088
559
|
'yum product id 1': true
|
|
1089
560
|
},
|
|
1090
561
|
offer: {
|
|
1091
|
-
config: {
|
|
1092
|
-
frequencies: ['yum selling plan id 1', 'yum selling plan id 4'],
|
|
1093
|
-
frequenciesEveryPeriod: ['1_1', '1_4']
|
|
1094
|
-
},
|
|
1095
562
|
defaultFrequency: '1_3'
|
|
563
|
+
},
|
|
564
|
+
frequencyConfig: {
|
|
565
|
+
frequencies: ['yum selling plan id 1', 'yum selling plan id 4'],
|
|
566
|
+
frequenciesEveryPeriod: ['1_1', '1_4']
|
|
1096
567
|
}
|
|
1097
568
|
}
|
|
1098
569
|
});
|
|
@@ -1127,7 +598,8 @@ describe('optedin', () => {
|
|
|
1127
598
|
},
|
|
1128
599
|
offer: {
|
|
1129
600
|
defaultFrequency: 'yum offer default frequency'
|
|
1130
|
-
}
|
|
601
|
+
},
|
|
602
|
+
frequencyConfig: {}
|
|
1131
603
|
}
|
|
1132
604
|
});
|
|
1133
605
|
expect(actual).toEqual([
|
|
@@ -1154,11 +626,11 @@ describe('optedin', () => {
|
|
|
1154
626
|
'yum product id 1': true
|
|
1155
627
|
},
|
|
1156
628
|
offer: {
|
|
1157
|
-
config: {
|
|
1158
|
-
frequencies: ['yum selling plan id 1'],
|
|
1159
|
-
frequenciesEveryPeriod: ['1_1']
|
|
1160
|
-
},
|
|
1161
629
|
defaultFrequency: 'yum offer default selling plan'
|
|
630
|
+
},
|
|
631
|
+
frequencyConfig: {
|
|
632
|
+
frequencies: ['yum selling plan id 1'],
|
|
633
|
+
frequenciesEveryPeriod: ['1_1']
|
|
1162
634
|
}
|
|
1163
635
|
}
|
|
1164
636
|
});
|
|
@@ -1185,11 +657,11 @@ describe('optedin', () => {
|
|
|
1185
657
|
'yum product id 1': true
|
|
1186
658
|
},
|
|
1187
659
|
offer: {
|
|
1188
|
-
config: {
|
|
1189
|
-
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
1190
|
-
frequenciesEveryPeriod: ['1_1', '1_2']
|
|
1191
|
-
},
|
|
1192
660
|
defaultFrequency: '1_2'
|
|
661
|
+
},
|
|
662
|
+
frequencyConfig: {
|
|
663
|
+
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
664
|
+
frequenciesEveryPeriod: ['1_1', '1_2']
|
|
1193
665
|
}
|
|
1194
666
|
}
|
|
1195
667
|
});
|
|
@@ -1216,11 +688,11 @@ describe('optedin', () => {
|
|
|
1216
688
|
'yum product id 1': true
|
|
1217
689
|
},
|
|
1218
690
|
offer: {
|
|
1219
|
-
config: {
|
|
1220
|
-
frequencies: ['yum selling plan id 1'],
|
|
1221
|
-
frequenciesEveryPeriod: ['1_1']
|
|
1222
|
-
},
|
|
1223
691
|
defaultFrequency: 'yum offer default selling plan'
|
|
692
|
+
},
|
|
693
|
+
frequencyConfig: {
|
|
694
|
+
frequencies: ['yum selling plan id 1'],
|
|
695
|
+
frequenciesEveryPeriod: ['1_1']
|
|
1224
696
|
}
|
|
1225
697
|
}
|
|
1226
698
|
});
|
|
@@ -1246,11 +718,11 @@ describe('optedin', () => {
|
|
|
1246
718
|
'yum product id 1': true
|
|
1247
719
|
},
|
|
1248
720
|
offer: {
|
|
1249
|
-
config: {
|
|
1250
|
-
frequencies: ['yum selling plan id 1', 'yum selling plan id 3'],
|
|
1251
|
-
frequenciesEveryPeriod: ['1_1', '1_3']
|
|
1252
|
-
},
|
|
1253
721
|
defaultFrequency: '1_3'
|
|
722
|
+
},
|
|
723
|
+
frequencyConfig: {
|
|
724
|
+
frequencies: ['yum selling plan id 1', 'yum selling plan id 3'],
|
|
725
|
+
frequenciesEveryPeriod: ['1_1', '1_3']
|
|
1254
726
|
}
|
|
1255
727
|
}
|
|
1256
728
|
});
|
|
@@ -1276,11 +748,11 @@ describe('optedin', () => {
|
|
|
1276
748
|
'yum product id 1': true
|
|
1277
749
|
},
|
|
1278
750
|
offer: {
|
|
1279
|
-
config: {
|
|
1280
|
-
frequencies: ['yum selling plan id 1', 'yum selling plan id 4'],
|
|
1281
|
-
frequenciesEveryPeriod: ['1_1', '1_4']
|
|
1282
|
-
},
|
|
1283
751
|
defaultFrequency: '1_3'
|
|
752
|
+
},
|
|
753
|
+
frequencyConfig: {
|
|
754
|
+
frequencies: ['yum selling plan id 1', 'yum selling plan id 4'],
|
|
755
|
+
frequenciesEveryPeriod: ['1_1', '1_4']
|
|
1284
756
|
}
|
|
1285
757
|
}
|
|
1286
758
|
});
|
|
@@ -1306,11 +778,10 @@ describe('optedin', () => {
|
|
|
1306
778
|
{
|
|
1307
779
|
type: constants.RECEIVE_OFFER,
|
|
1308
780
|
payload: {
|
|
1309
|
-
offer: {
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
}
|
|
781
|
+
offer: {},
|
|
782
|
+
frequencyConfig: {
|
|
783
|
+
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
784
|
+
frequenciesEveryPeriod: ['1_1', '1_2']
|
|
1314
785
|
}
|
|
1315
786
|
}
|
|
1316
787
|
}
|
|
@@ -1520,33 +991,21 @@ describe('optedin', () => {
|
|
|
1520
991
|
});
|
|
1521
992
|
|
|
1522
993
|
describe('given action is PRODUCT_CHANGE_PREPAID_SHIPMENTS', () => {
|
|
1523
|
-
function getPayload(prepaidShipments) {
|
|
994
|
+
function getPayload(prepaidShipments, frequency) {
|
|
1524
995
|
return {
|
|
1525
996
|
product: {
|
|
1526
997
|
id: 'yum prepaid id'
|
|
1527
998
|
},
|
|
1528
999
|
prepaidShipments: prepaidShipments,
|
|
1529
|
-
offer: {
|
|
1530
|
-
|
|
1531
|
-
prepaidSellingPlans: {
|
|
1532
|
-
'yum prepaid id': [
|
|
1533
|
-
{ numberShipments: 3, sellingPlan: 'yum prepaid selling plan id 1' },
|
|
1534
|
-
{
|
|
1535
|
-
numberShipments: 4,
|
|
1536
|
-
sellingPlan: 'yum prepaid selling plan id 2'
|
|
1537
|
-
}
|
|
1538
|
-
]
|
|
1539
|
-
},
|
|
1540
|
-
frequencies: ['yum selling plan id 1']
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1000
|
+
offer: {},
|
|
1001
|
+
frequency
|
|
1543
1002
|
};
|
|
1544
1003
|
}
|
|
1545
1004
|
|
|
1546
|
-
it('
|
|
1005
|
+
it('opts into the given frequency and shipments', () => {
|
|
1547
1006
|
const actual = optedin([], {
|
|
1548
1007
|
type: constants.PRODUCT_CHANGE_PREPAID_SHIPMENTS,
|
|
1549
|
-
payload: getPayload(4)
|
|
1008
|
+
payload: getPayload(4, 'yum prepaid selling plan id 2')
|
|
1550
1009
|
});
|
|
1551
1010
|
expect(actual).toEqual([
|
|
1552
1011
|
{
|
|
@@ -1557,19 +1016,6 @@ describe('optedin', () => {
|
|
|
1557
1016
|
]);
|
|
1558
1017
|
});
|
|
1559
1018
|
|
|
1560
|
-
it('sets frequency to the first frequency when prepaidShipments is null', () => {
|
|
1561
|
-
const actual = optedin([], {
|
|
1562
|
-
type: constants.PRODUCT_CHANGE_PREPAID_SHIPMENTS,
|
|
1563
|
-
payload: getPayload(null)
|
|
1564
|
-
});
|
|
1565
|
-
expect(actual).toEqual([
|
|
1566
|
-
{
|
|
1567
|
-
id: 'yum prepaid id',
|
|
1568
|
-
frequency: 'yum selling plan id 1'
|
|
1569
|
-
}
|
|
1570
|
-
]);
|
|
1571
|
-
});
|
|
1572
|
-
|
|
1573
1019
|
it('updates existing opted in state', () => {
|
|
1574
1020
|
const actual = optedin(
|
|
1575
1021
|
[
|
|
@@ -1580,7 +1026,7 @@ describe('optedin', () => {
|
|
|
1580
1026
|
],
|
|
1581
1027
|
{
|
|
1582
1028
|
type: constants.PRODUCT_CHANGE_PREPAID_SHIPMENTS,
|
|
1583
|
-
payload: getPayload(4)
|
|
1029
|
+
payload: getPayload(4, 'yum prepaid selling plan id 2')
|
|
1584
1030
|
}
|
|
1585
1031
|
);
|
|
1586
1032
|
expect(actual).toEqual([
|
|
@@ -1620,19 +1066,6 @@ function getSetupProductActionForRegularProduct(currency = 'USD') {
|
|
|
1620
1066
|
payload: {
|
|
1621
1067
|
product: {
|
|
1622
1068
|
id: 'yum product id',
|
|
1623
|
-
selling_plan_allocations: [
|
|
1624
|
-
{
|
|
1625
|
-
selling_plan_id: 'yum selling plan id 1',
|
|
1626
|
-
compare_at_price: 100,
|
|
1627
|
-
price: 50,
|
|
1628
|
-
price_adjustments: [
|
|
1629
|
-
{
|
|
1630
|
-
value: 50,
|
|
1631
|
-
value_type: 'percentage'
|
|
1632
|
-
}
|
|
1633
|
-
]
|
|
1634
|
-
}
|
|
1635
|
-
],
|
|
1636
1069
|
variants: [
|
|
1637
1070
|
{
|
|
1638
1071
|
id: 'yum variant id 1',
|
|
@@ -1703,18 +1136,6 @@ function getSetupProductActionForPrepaidProduct(currency = 'USD') {
|
|
|
1703
1136
|
payload: {
|
|
1704
1137
|
product: {
|
|
1705
1138
|
id: 'yum product id',
|
|
1706
|
-
selling_plan_allocations: [
|
|
1707
|
-
{
|
|
1708
|
-
selling_plan_id: 'yum selling plan id 1',
|
|
1709
|
-
compare_at_price: 2000,
|
|
1710
|
-
price: 4800,
|
|
1711
|
-
price_adjustments: [
|
|
1712
|
-
{
|
|
1713
|
-
value: 4800
|
|
1714
|
-
}
|
|
1715
|
-
]
|
|
1716
|
-
}
|
|
1717
|
-
],
|
|
1718
1139
|
variants: [
|
|
1719
1140
|
{
|
|
1720
1141
|
id: 'yum variant id 1',
|
|
@@ -1972,15 +1393,6 @@ describe('productPlans', () => {
|
|
|
1972
1393
|
const actual = productPlans({}, getSetupProductActionForRegularProduct());
|
|
1973
1394
|
|
|
1974
1395
|
expect(actual).toEqual({
|
|
1975
|
-
'yum product id': [
|
|
1976
|
-
{
|
|
1977
|
-
frequency: 'yum selling plan id 1',
|
|
1978
|
-
prepaidShipments: null,
|
|
1979
|
-
regularPrice: '$1.00',
|
|
1980
|
-
subscriptionPrice: '$0.50',
|
|
1981
|
-
discountRate: '50%'
|
|
1982
|
-
}
|
|
1983
|
-
],
|
|
1984
1396
|
'yum variant id 1': [
|
|
1985
1397
|
{
|
|
1986
1398
|
frequency: 'yum selling plan id 2',
|
|
@@ -2006,18 +1418,6 @@ describe('productPlans', () => {
|
|
|
2006
1418
|
const actual = productPlans({}, getSetupProductActionForPrepaidProduct());
|
|
2007
1419
|
|
|
2008
1420
|
expect(actual).toEqual({
|
|
2009
|
-
'yum product id': [
|
|
2010
|
-
{
|
|
2011
|
-
frequency: 'yum selling plan id 1',
|
|
2012
|
-
regularPrice: '$20.00',
|
|
2013
|
-
subscriptionPrice: '$16.00',
|
|
2014
|
-
discountRate: '20%',
|
|
2015
|
-
prepaidShipments: 3,
|
|
2016
|
-
regularPrepaidPrice: '$48.00',
|
|
2017
|
-
prepaidSavingsPerShipment: '$4.00',
|
|
2018
|
-
prepaidSavingsTotal: '$12.00'
|
|
2019
|
-
}
|
|
2020
|
-
],
|
|
2021
1421
|
'yum variant id 1': [
|
|
2022
1422
|
{
|
|
2023
1423
|
frequency: 'yum selling plan id 2',
|
|
@@ -2073,15 +1473,6 @@ describe('productPlans', () => {
|
|
|
2073
1473
|
const actual = productPlans({}, getSetupProductActionForRegularProduct('GBP'));
|
|
2074
1474
|
|
|
2075
1475
|
expect(actual).toEqual({
|
|
2076
|
-
'yum product id': [
|
|
2077
|
-
{
|
|
2078
|
-
frequency: 'yum selling plan id 1',
|
|
2079
|
-
prepaidShipments: null,
|
|
2080
|
-
regularPrice: '£1.00',
|
|
2081
|
-
subscriptionPrice: '£0.50',
|
|
2082
|
-
discountRate: '50%'
|
|
2083
|
-
}
|
|
2084
|
-
],
|
|
2085
1476
|
'yum variant id 1': [
|
|
2086
1477
|
{
|
|
2087
1478
|
frequency: 'yum selling plan id 2',
|
|
@@ -2181,49 +1572,6 @@ describe('productPlans', () => {
|
|
|
2181
1572
|
});
|
|
2182
1573
|
});
|
|
2183
1574
|
|
|
2184
|
-
it('should return object structure payload given action RECEIVE_PRODUCT_PLANS', () => {
|
|
2185
|
-
const payload = {
|
|
2186
|
-
'variant-1': {
|
|
2187
|
-
'1_3': ['$15.00', '10%', '$13.50'],
|
|
2188
|
-
'2_3': ['$15.00', '10%', '$13.50'],
|
|
2189
|
-
'3_3': ['$15.00', '20%', '$12.00']
|
|
2190
|
-
},
|
|
2191
|
-
'variant-2': [
|
|
2192
|
-
{
|
|
2193
|
-
frequency: '1_3',
|
|
2194
|
-
prepaidShipments: null,
|
|
2195
|
-
regularPrice: '$30.00',
|
|
2196
|
-
subscriptionPrice: '$27.00',
|
|
2197
|
-
discountRate: '10%'
|
|
2198
|
-
},
|
|
2199
|
-
{
|
|
2200
|
-
frequency: '2_3',
|
|
2201
|
-
prepaidShipments: null,
|
|
2202
|
-
regularPrice: '$30.00',
|
|
2203
|
-
subscriptionPrice: '$27.00',
|
|
2204
|
-
discountRate: '10%'
|
|
2205
|
-
},
|
|
2206
|
-
{
|
|
2207
|
-
frequency: '3_3',
|
|
2208
|
-
prepaidShipments: 3,
|
|
2209
|
-
regularPrice: '$30.00',
|
|
2210
|
-
subscriptionPrice: '$24.00',
|
|
2211
|
-
discountRate: '20%'
|
|
2212
|
-
}
|
|
2213
|
-
]
|
|
2214
|
-
};
|
|
2215
|
-
|
|
2216
|
-
const actual = productPlans(
|
|
2217
|
-
{},
|
|
2218
|
-
{
|
|
2219
|
-
type: constants.RECEIVE_PRODUCT_PLANS,
|
|
2220
|
-
payload: payload
|
|
2221
|
-
}
|
|
2222
|
-
);
|
|
2223
|
-
|
|
2224
|
-
expect(actual).toEqual(getObjectStructuredProductPlans(payload));
|
|
2225
|
-
});
|
|
2226
|
-
|
|
2227
1575
|
it('should return unmodified state given unsupported action', () => {
|
|
2228
1576
|
const actual = productPlans(
|
|
2229
1577
|
{ 'yum existing key': 'yum existing value' },
|
|
@@ -2236,26 +1584,3 @@ describe('productPlans', () => {
|
|
|
2236
1584
|
expect(actual).toEqual({ 'yum existing key': 'yum existing value' });
|
|
2237
1585
|
});
|
|
2238
1586
|
});
|
|
2239
|
-
|
|
2240
|
-
describe('textToFreq', () => {
|
|
2241
|
-
it('textToFreq should return freq', () => {
|
|
2242
|
-
expect(textToFreq('DAY')).toEqual('1_1');
|
|
2243
|
-
expect(textToFreq('DAYS')).toEqual('1_1');
|
|
2244
|
-
expect(textToFreq('DAYLY')).toEqual('1_1');
|
|
2245
|
-
expect(textToFreq('1 DAY')).toEqual('1_1');
|
|
2246
|
-
expect(textToFreq('2 DAYS')).toEqual('2_1');
|
|
2247
|
-
expect(textToFreq('2 day(s)')).toEqual('2_1');
|
|
2248
|
-
|
|
2249
|
-
expect(textToFreq('week')).toEqual('1_2');
|
|
2250
|
-
expect(textToFreq('weekly')).toEqual('1_2');
|
|
2251
|
-
expect(textToFreq('1 week')).toEqual('1_2');
|
|
2252
|
-
expect(textToFreq('2 weeks')).toEqual('2_2');
|
|
2253
|
-
expect(textToFreq('2 week(s)')).toEqual('2_2');
|
|
2254
|
-
|
|
2255
|
-
expect(textToFreq('MONTH')).toEqual('1_3');
|
|
2256
|
-
expect(textToFreq('MONTHLY')).toEqual('1_3');
|
|
2257
|
-
expect(textToFreq('1 month')).toEqual('1_3');
|
|
2258
|
-
expect(textToFreq('2 months')).toEqual('2_3');
|
|
2259
|
-
expect(textToFreq('2 month(s)')).toEqual('2_3');
|
|
2260
|
-
});
|
|
2261
|
-
});
|