@ordergroove/offers 2.44.0 → 2.44.1-alpha-PR-1166-3.30
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 +52 -49
- package/dist/offers.js +38 -38
- package/dist/offers.js.map +4 -4
- package/package.json +2 -2
- package/src/components/FrequencyStatus.js +13 -10
- package/src/components/Offer.js +33 -14
- package/src/components/OptinButton.js +2 -2
- package/src/components/OptinSelect.js +5 -5
- package/src/components/OptinStatus.js +15 -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__/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.js → selectors.ts} +73 -57
- package/src/core/types/api.ts +71 -0
- package/src/core/types/reducer.ts +95 -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 +497 -0
- package/src/shopify/__tests__/shopifyReducer.spec.js +65 -610
- package/src/shopify/__tests__/utils.spec.js +24 -1
- package/src/shopify/reducers/config.ts +223 -0
- package/src/shopify/shopifyMiddleware.ts +2 -9
- package/src/shopify/{shopifyReducer.js → shopifyReducer.ts} +45 -177
- package/src/shopify/utils.ts +25 -0
- package/src/types.ts +0 -16
|
@@ -1,14 +1,5 @@
|
|
|
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
|
|
|
@@ -174,491 +165,6 @@ describe('autoshipEligible', () => {
|
|
|
174
165
|
});
|
|
175
166
|
});
|
|
176
167
|
|
|
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
168
|
describe('inStock', () => {
|
|
663
169
|
it('should return true for each id given action RECEIVE_PRODUCT_PLANS', () => {
|
|
664
170
|
const actual = inStock(
|
|
@@ -847,11 +353,10 @@ describe('optedin', () => {
|
|
|
847
353
|
{
|
|
848
354
|
type: constants.RECEIVE_OFFER,
|
|
849
355
|
payload: {
|
|
850
|
-
offer: {
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
}
|
|
356
|
+
offer: {},
|
|
357
|
+
frequencyConfig: {
|
|
358
|
+
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
359
|
+
frequenciesEveryPeriod: ['1_1', '1_2']
|
|
855
360
|
}
|
|
856
361
|
}
|
|
857
362
|
}
|
|
@@ -877,11 +382,11 @@ describe('optedin', () => {
|
|
|
877
382
|
type: constants.RECEIVE_OFFER,
|
|
878
383
|
payload: {
|
|
879
384
|
offer: {
|
|
880
|
-
config: {
|
|
881
|
-
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
882
|
-
frequenciesEveryPeriod: ['3_1', '3_2']
|
|
883
|
-
},
|
|
884
385
|
defaultFrequency: '3_2'
|
|
386
|
+
},
|
|
387
|
+
frequencyConfig: {
|
|
388
|
+
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
389
|
+
frequenciesEveryPeriod: ['3_1', '3_2']
|
|
885
390
|
}
|
|
886
391
|
}
|
|
887
392
|
}
|
|
@@ -906,11 +411,10 @@ describe('optedin', () => {
|
|
|
906
411
|
{
|
|
907
412
|
type: constants.RECEIVE_OFFER,
|
|
908
413
|
payload: {
|
|
909
|
-
offer: {
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
}
|
|
414
|
+
offer: {},
|
|
415
|
+
frequencyConfig: {
|
|
416
|
+
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
417
|
+
frequenciesEveryPeriod: ['3_1', '3_2']
|
|
914
418
|
}
|
|
915
419
|
}
|
|
916
420
|
}
|
|
@@ -936,11 +440,10 @@ describe('optedin', () => {
|
|
|
936
440
|
{
|
|
937
441
|
type: constants.RECEIVE_OFFER,
|
|
938
442
|
payload: {
|
|
939
|
-
offer: {
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
}
|
|
443
|
+
offer: {},
|
|
444
|
+
frequencyConfig: {
|
|
445
|
+
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
446
|
+
frequenciesEveryPeriod: ['1_1', '1_2']
|
|
944
447
|
}
|
|
945
448
|
}
|
|
946
449
|
}
|
|
@@ -979,11 +482,11 @@ describe('optedin', () => {
|
|
|
979
482
|
'yum product id 1': true
|
|
980
483
|
},
|
|
981
484
|
offer: {
|
|
982
|
-
config: {
|
|
983
|
-
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
984
|
-
frequenciesEveryPeriod: ['1_1', '1_2']
|
|
985
|
-
},
|
|
986
485
|
defaultFrequency: 'yum offer default frequency'
|
|
486
|
+
},
|
|
487
|
+
frequencyConfig: {
|
|
488
|
+
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
489
|
+
frequenciesEveryPeriod: ['1_1', '1_2']
|
|
987
490
|
}
|
|
988
491
|
}
|
|
989
492
|
});
|
|
@@ -1016,11 +519,11 @@ describe('optedin', () => {
|
|
|
1016
519
|
'yum product id 1': true
|
|
1017
520
|
},
|
|
1018
521
|
offer: {
|
|
1019
|
-
config: {
|
|
1020
|
-
frequencies: ['yum selling plan id 1'],
|
|
1021
|
-
frequenciesEveryPeriod: ['1_1']
|
|
1022
|
-
},
|
|
1023
522
|
defaultFrequency: 'yum offer default selling plan'
|
|
523
|
+
},
|
|
524
|
+
frequencyConfig: {
|
|
525
|
+
frequencies: ['yum selling plan id 1'],
|
|
526
|
+
frequenciesEveryPeriod: ['1_1']
|
|
1024
527
|
}
|
|
1025
528
|
}
|
|
1026
529
|
});
|
|
@@ -1052,11 +555,11 @@ describe('optedin', () => {
|
|
|
1052
555
|
'yum product id 1': true
|
|
1053
556
|
},
|
|
1054
557
|
offer: {
|
|
1055
|
-
config: {
|
|
1056
|
-
frequencies: ['yum selling plan id 1', 'yum selling plan id 3'],
|
|
1057
|
-
frequenciesEveryPeriod: ['1_1', '1_3']
|
|
1058
|
-
},
|
|
1059
558
|
defaultFrequency: '1_3'
|
|
559
|
+
},
|
|
560
|
+
frequencyConfig: {
|
|
561
|
+
frequencies: ['yum selling plan id 1', 'yum selling plan id 3'],
|
|
562
|
+
frequenciesEveryPeriod: ['1_1', '1_3']
|
|
1060
563
|
}
|
|
1061
564
|
}
|
|
1062
565
|
});
|
|
@@ -1088,11 +591,11 @@ describe('optedin', () => {
|
|
|
1088
591
|
'yum product id 1': true
|
|
1089
592
|
},
|
|
1090
593
|
offer: {
|
|
1091
|
-
config: {
|
|
1092
|
-
frequencies: ['yum selling plan id 1', 'yum selling plan id 4'],
|
|
1093
|
-
frequenciesEveryPeriod: ['1_1', '1_4']
|
|
1094
|
-
},
|
|
1095
594
|
defaultFrequency: '1_3'
|
|
595
|
+
},
|
|
596
|
+
frequencyConfig: {
|
|
597
|
+
frequencies: ['yum selling plan id 1', 'yum selling plan id 4'],
|
|
598
|
+
frequenciesEveryPeriod: ['1_1', '1_4']
|
|
1096
599
|
}
|
|
1097
600
|
}
|
|
1098
601
|
});
|
|
@@ -1127,7 +630,8 @@ describe('optedin', () => {
|
|
|
1127
630
|
},
|
|
1128
631
|
offer: {
|
|
1129
632
|
defaultFrequency: 'yum offer default frequency'
|
|
1130
|
-
}
|
|
633
|
+
},
|
|
634
|
+
frequencyConfig: {}
|
|
1131
635
|
}
|
|
1132
636
|
});
|
|
1133
637
|
expect(actual).toEqual([
|
|
@@ -1154,11 +658,11 @@ describe('optedin', () => {
|
|
|
1154
658
|
'yum product id 1': true
|
|
1155
659
|
},
|
|
1156
660
|
offer: {
|
|
1157
|
-
config: {
|
|
1158
|
-
frequencies: ['yum selling plan id 1'],
|
|
1159
|
-
frequenciesEveryPeriod: ['1_1']
|
|
1160
|
-
},
|
|
1161
661
|
defaultFrequency: 'yum offer default selling plan'
|
|
662
|
+
},
|
|
663
|
+
frequencyConfig: {
|
|
664
|
+
frequencies: ['yum selling plan id 1'],
|
|
665
|
+
frequenciesEveryPeriod: ['1_1']
|
|
1162
666
|
}
|
|
1163
667
|
}
|
|
1164
668
|
});
|
|
@@ -1185,11 +689,11 @@ describe('optedin', () => {
|
|
|
1185
689
|
'yum product id 1': true
|
|
1186
690
|
},
|
|
1187
691
|
offer: {
|
|
1188
|
-
config: {
|
|
1189
|
-
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
1190
|
-
frequenciesEveryPeriod: ['1_1', '1_2']
|
|
1191
|
-
},
|
|
1192
692
|
defaultFrequency: '1_2'
|
|
693
|
+
},
|
|
694
|
+
frequencyConfig: {
|
|
695
|
+
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
696
|
+
frequenciesEveryPeriod: ['1_1', '1_2']
|
|
1193
697
|
}
|
|
1194
698
|
}
|
|
1195
699
|
});
|
|
@@ -1216,11 +720,11 @@ describe('optedin', () => {
|
|
|
1216
720
|
'yum product id 1': true
|
|
1217
721
|
},
|
|
1218
722
|
offer: {
|
|
1219
|
-
config: {
|
|
1220
|
-
frequencies: ['yum selling plan id 1'],
|
|
1221
|
-
frequenciesEveryPeriod: ['1_1']
|
|
1222
|
-
},
|
|
1223
723
|
defaultFrequency: 'yum offer default selling plan'
|
|
724
|
+
},
|
|
725
|
+
frequencyConfig: {
|
|
726
|
+
frequencies: ['yum selling plan id 1'],
|
|
727
|
+
frequenciesEveryPeriod: ['1_1']
|
|
1224
728
|
}
|
|
1225
729
|
}
|
|
1226
730
|
});
|
|
@@ -1246,11 +750,11 @@ describe('optedin', () => {
|
|
|
1246
750
|
'yum product id 1': true
|
|
1247
751
|
},
|
|
1248
752
|
offer: {
|
|
1249
|
-
config: {
|
|
1250
|
-
frequencies: ['yum selling plan id 1', 'yum selling plan id 3'],
|
|
1251
|
-
frequenciesEveryPeriod: ['1_1', '1_3']
|
|
1252
|
-
},
|
|
1253
753
|
defaultFrequency: '1_3'
|
|
754
|
+
},
|
|
755
|
+
frequencyConfig: {
|
|
756
|
+
frequencies: ['yum selling plan id 1', 'yum selling plan id 3'],
|
|
757
|
+
frequenciesEveryPeriod: ['1_1', '1_3']
|
|
1254
758
|
}
|
|
1255
759
|
}
|
|
1256
760
|
});
|
|
@@ -1276,11 +780,11 @@ describe('optedin', () => {
|
|
|
1276
780
|
'yum product id 1': true
|
|
1277
781
|
},
|
|
1278
782
|
offer: {
|
|
1279
|
-
config: {
|
|
1280
|
-
frequencies: ['yum selling plan id 1', 'yum selling plan id 4'],
|
|
1281
|
-
frequenciesEveryPeriod: ['1_1', '1_4']
|
|
1282
|
-
},
|
|
1283
783
|
defaultFrequency: '1_3'
|
|
784
|
+
},
|
|
785
|
+
frequencyConfig: {
|
|
786
|
+
frequencies: ['yum selling plan id 1', 'yum selling plan id 4'],
|
|
787
|
+
frequenciesEveryPeriod: ['1_1', '1_4']
|
|
1284
788
|
}
|
|
1285
789
|
}
|
|
1286
790
|
});
|
|
@@ -1306,11 +810,10 @@ describe('optedin', () => {
|
|
|
1306
810
|
{
|
|
1307
811
|
type: constants.RECEIVE_OFFER,
|
|
1308
812
|
payload: {
|
|
1309
|
-
offer: {
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
}
|
|
813
|
+
offer: {},
|
|
814
|
+
frequencyConfig: {
|
|
815
|
+
frequencies: ['yum selling plan id 1', 'yum selling plan id 2'],
|
|
816
|
+
frequenciesEveryPeriod: ['1_1', '1_2']
|
|
1314
817
|
}
|
|
1315
818
|
}
|
|
1316
819
|
}
|
|
@@ -1520,33 +1023,21 @@ describe('optedin', () => {
|
|
|
1520
1023
|
});
|
|
1521
1024
|
|
|
1522
1025
|
describe('given action is PRODUCT_CHANGE_PREPAID_SHIPMENTS', () => {
|
|
1523
|
-
function getPayload(prepaidShipments) {
|
|
1026
|
+
function getPayload(prepaidShipments, frequency) {
|
|
1524
1027
|
return {
|
|
1525
1028
|
product: {
|
|
1526
1029
|
id: 'yum prepaid id'
|
|
1527
1030
|
},
|
|
1528
1031
|
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
|
-
}
|
|
1032
|
+
offer: {},
|
|
1033
|
+
frequency
|
|
1543
1034
|
};
|
|
1544
1035
|
}
|
|
1545
1036
|
|
|
1546
|
-
it('
|
|
1037
|
+
it('opts into the given frequency and shipments', () => {
|
|
1547
1038
|
const actual = optedin([], {
|
|
1548
1039
|
type: constants.PRODUCT_CHANGE_PREPAID_SHIPMENTS,
|
|
1549
|
-
payload: getPayload(4)
|
|
1040
|
+
payload: getPayload(4, 'yum prepaid selling plan id 2')
|
|
1550
1041
|
});
|
|
1551
1042
|
expect(actual).toEqual([
|
|
1552
1043
|
{
|
|
@@ -1557,19 +1048,6 @@ describe('optedin', () => {
|
|
|
1557
1048
|
]);
|
|
1558
1049
|
});
|
|
1559
1050
|
|
|
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
1051
|
it('updates existing opted in state', () => {
|
|
1574
1052
|
const actual = optedin(
|
|
1575
1053
|
[
|
|
@@ -1580,7 +1058,7 @@ describe('optedin', () => {
|
|
|
1580
1058
|
],
|
|
1581
1059
|
{
|
|
1582
1060
|
type: constants.PRODUCT_CHANGE_PREPAID_SHIPMENTS,
|
|
1583
|
-
payload: getPayload(4)
|
|
1061
|
+
payload: getPayload(4, 'yum prepaid selling plan id 2')
|
|
1584
1062
|
}
|
|
1585
1063
|
);
|
|
1586
1064
|
expect(actual).toEqual([
|
|
@@ -2236,26 +1714,3 @@ describe('productPlans', () => {
|
|
|
2236
1714
|
expect(actual).toEqual({ 'yum existing key': 'yum existing value' });
|
|
2237
1715
|
});
|
|
2238
1716
|
});
|
|
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
|
-
});
|