@darkpos/pricing 1.0.97 → 1.0.100
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/__TEST__/item.test.js +25 -0
- package/__TEST__/modifier/addItemModifier.test.js +138 -0
- package/__TEST__/modifier.test.js +10 -142
- package/__TEST__/order/conditionsNotMet.test.js +309 -58
- package/__TEST__/order/order-payment-modifier.test.js +10 -8
- package/__TEST__/order/order.test.js +18 -12
- package/lib/item/calculate.js +10 -11
- package/lib/item/index.js +2 -0
- package/lib/item/removeModifier.js +15 -18
- package/lib/item/validateModifiers.js +71 -0
- package/lib/modifier/getDepartmentModifiers.js +1 -1
- package/lib/modifier/getInheritedModifiers.js +1 -1
- package/lib/modifier/index.js +0 -2
- package/lib/order/addItemModifier.js +8 -87
- package/lib/order/removeItemModifier.js +8 -1
- package/package.json +2 -2
- package/lib/modifier/purifyModifiers.js +0 -15
package/__TEST__/item.test.js
CHANGED
|
@@ -11,6 +11,7 @@ describe('Item actions', () => {
|
|
|
11
11
|
test('Get calculated Item: included: false && direct: false', () => {
|
|
12
12
|
const modifiers = [
|
|
13
13
|
{
|
|
14
|
+
_id: 1111,
|
|
14
15
|
compute: {
|
|
15
16
|
amount: 20,
|
|
16
17
|
type: 'percentage',
|
|
@@ -25,6 +26,7 @@ describe('Item actions', () => {
|
|
|
25
26
|
},
|
|
26
27
|
},
|
|
27
28
|
{
|
|
29
|
+
_id: 2222,
|
|
28
30
|
compute: {
|
|
29
31
|
amount: 20,
|
|
30
32
|
type: 'percentage',
|
|
@@ -39,6 +41,7 @@ describe('Item actions', () => {
|
|
|
39
41
|
},
|
|
40
42
|
},
|
|
41
43
|
{
|
|
44
|
+
_id: 3333,
|
|
42
45
|
compute: {
|
|
43
46
|
amount: 2,
|
|
44
47
|
type: 'fixed',
|
|
@@ -69,6 +72,7 @@ describe('Item actions', () => {
|
|
|
69
72
|
test('Get calculated Item: included: false && direct: true', () => {
|
|
70
73
|
const modifiers = [
|
|
71
74
|
{
|
|
75
|
+
_id: '123213213',
|
|
72
76
|
compute: { amount: 2, type: 'fixed', action: 'subtract' },
|
|
73
77
|
type: 'discount',
|
|
74
78
|
name: 'modifier1',
|
|
@@ -79,6 +83,7 @@ describe('Item actions', () => {
|
|
|
79
83
|
},
|
|
80
84
|
},
|
|
81
85
|
{
|
|
86
|
+
_id: '22222',
|
|
82
87
|
compute: {
|
|
83
88
|
amount: 20,
|
|
84
89
|
type: 'percentage',
|
|
@@ -93,6 +98,7 @@ describe('Item actions', () => {
|
|
|
93
98
|
},
|
|
94
99
|
},
|
|
95
100
|
{
|
|
101
|
+
_id: '3333',
|
|
96
102
|
compute: {
|
|
97
103
|
amount: 2,
|
|
98
104
|
type: 'fixed',
|
|
@@ -124,6 +130,7 @@ describe('Item actions', () => {
|
|
|
124
130
|
test('Get calculated Item: included: true && direct: true', () => {
|
|
125
131
|
const modifiers = [
|
|
126
132
|
{
|
|
133
|
+
_id: '111111',
|
|
127
134
|
compute: {
|
|
128
135
|
amount: 2,
|
|
129
136
|
type: 'fixed',
|
|
@@ -138,6 +145,8 @@ describe('Item actions', () => {
|
|
|
138
145
|
},
|
|
139
146
|
},
|
|
140
147
|
{
|
|
148
|
+
_id: '222222',
|
|
149
|
+
|
|
141
150
|
compute: {
|
|
142
151
|
amount: 20,
|
|
143
152
|
type: 'percentage',
|
|
@@ -152,6 +161,8 @@ describe('Item actions', () => {
|
|
|
152
161
|
},
|
|
153
162
|
},
|
|
154
163
|
{
|
|
164
|
+
_id: '33333',
|
|
165
|
+
|
|
155
166
|
compute: {
|
|
156
167
|
amount: 2,
|
|
157
168
|
type: 'fixed',
|
|
@@ -215,6 +226,7 @@ describe('Item actions', () => {
|
|
|
215
226
|
properties: {
|
|
216
227
|
sort: 1,
|
|
217
228
|
},
|
|
229
|
+
_id: '1255115',
|
|
218
230
|
},
|
|
219
231
|
{
|
|
220
232
|
compute: {
|
|
@@ -229,6 +241,7 @@ describe('Item actions', () => {
|
|
|
229
241
|
},
|
|
230
242
|
included: true,
|
|
231
243
|
direct: true,
|
|
244
|
+
_id: '2256659',
|
|
232
245
|
},
|
|
233
246
|
];
|
|
234
247
|
const orderItem = { price: 2, quantity: 1, modifiers };
|
|
@@ -246,6 +259,7 @@ describe('Item actions', () => {
|
|
|
246
259
|
test('Get calculated Item: included: true, sample 3', () => {
|
|
247
260
|
const modifiers = [
|
|
248
261
|
{
|
|
262
|
+
_id: 12323,
|
|
249
263
|
compute: {
|
|
250
264
|
amount: 2,
|
|
251
265
|
type: 'fixed',
|
|
@@ -260,6 +274,7 @@ describe('Item actions', () => {
|
|
|
260
274
|
direct: true,
|
|
261
275
|
},
|
|
262
276
|
{
|
|
277
|
+
_id: 5555,
|
|
263
278
|
compute: {
|
|
264
279
|
amount: 2,
|
|
265
280
|
type: 'fixed',
|
|
@@ -274,6 +289,7 @@ describe('Item actions', () => {
|
|
|
274
289
|
},
|
|
275
290
|
},
|
|
276
291
|
{
|
|
292
|
+
_id: 77777,
|
|
277
293
|
compute: {
|
|
278
294
|
amount: 10,
|
|
279
295
|
type: 'percentage',
|
|
@@ -288,6 +304,7 @@ describe('Item actions', () => {
|
|
|
288
304
|
direct: true,
|
|
289
305
|
},
|
|
290
306
|
{
|
|
307
|
+
_id: 8888,
|
|
291
308
|
compute: {
|
|
292
309
|
amount: 6,
|
|
293
310
|
type: 'percentage',
|
|
@@ -479,6 +496,8 @@ describe('Item actions', () => {
|
|
|
479
496
|
},
|
|
480
497
|
name: 'fixedFee16',
|
|
481
498
|
type: 'tax',
|
|
499
|
+
modifierId: '11111',
|
|
500
|
+
_id: '123',
|
|
482
501
|
};
|
|
483
502
|
|
|
484
503
|
const fixedFee10 = {
|
|
@@ -489,6 +508,8 @@ describe('Item actions', () => {
|
|
|
489
508
|
},
|
|
490
509
|
name: 'fixedFee10',
|
|
491
510
|
type: 'tax',
|
|
511
|
+
modifierId: '22222',
|
|
512
|
+
_id: '234',
|
|
492
513
|
};
|
|
493
514
|
|
|
494
515
|
const orderItem = {
|
|
@@ -528,6 +549,8 @@ describe('Item actions', () => {
|
|
|
528
549
|
},
|
|
529
550
|
name: 'fixedFee16',
|
|
530
551
|
type: 'tax',
|
|
552
|
+
_id: '123',
|
|
553
|
+
modifierId: 1111,
|
|
531
554
|
};
|
|
532
555
|
|
|
533
556
|
const percentageFee10 = {
|
|
@@ -538,6 +561,8 @@ describe('Item actions', () => {
|
|
|
538
561
|
},
|
|
539
562
|
name: 'percentageFee10',
|
|
540
563
|
type: 'tax',
|
|
564
|
+
_id: '234',
|
|
565
|
+
modifierId: 222,
|
|
541
566
|
};
|
|
542
567
|
|
|
543
568
|
const orderItem = {
|
|
@@ -236,4 +236,142 @@ describe('addItemModifier Function', () => {
|
|
|
236
236
|
pricingService.order.addItemModifier(invalidModifierMock, orderMock);
|
|
237
237
|
}).toThrow(Error); // Expect an error to be thrown with invalid input
|
|
238
238
|
});
|
|
239
|
+
|
|
240
|
+
test('Add department modifier with customerTagsExtend and confirm price is correct, then remove it and confirm correct price again.', () => {
|
|
241
|
+
const order = {
|
|
242
|
+
_id: '68532dec3d51e6291225ccd9',
|
|
243
|
+
|
|
244
|
+
items: [
|
|
245
|
+
{
|
|
246
|
+
pieces: 2,
|
|
247
|
+
|
|
248
|
+
total: 129,
|
|
249
|
+
price: 129,
|
|
250
|
+
quantity: 1,
|
|
251
|
+
modifiers: [],
|
|
252
|
+
tags: ['default'],
|
|
253
|
+
category: null,
|
|
254
|
+
__typename: 'OrderItem',
|
|
255
|
+
priceLevels: [
|
|
256
|
+
{
|
|
257
|
+
value: 129,
|
|
258
|
+
tags: ['default'],
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
value: 15,
|
|
262
|
+
tags: ['default', 'vip'],
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
value: 10,
|
|
266
|
+
tags: ['default', 'rich'],
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
costLevels: [],
|
|
270
|
+
itemId: '67fea241af24e570c032b319',
|
|
271
|
+
subTotals: {},
|
|
272
|
+
},
|
|
273
|
+
],
|
|
274
|
+
notes: [],
|
|
275
|
+
customer: {
|
|
276
|
+
_id: '67feae8eeb5aa1e1848374b9',
|
|
277
|
+
tags: ['default'],
|
|
278
|
+
},
|
|
279
|
+
start: {
|
|
280
|
+
location: {
|
|
281
|
+
name: 'Sunshine Cleaners',
|
|
282
|
+
locationType: 'store',
|
|
283
|
+
storeId: '67e1c09c05b96100127280a8',
|
|
284
|
+
},
|
|
285
|
+
requestDate: '2025-06-18T21:21:48.745Z',
|
|
286
|
+
},
|
|
287
|
+
|
|
288
|
+
_storeId: '',
|
|
289
|
+
__typename: 'Order',
|
|
290
|
+
subTotals: {},
|
|
291
|
+
};
|
|
292
|
+
const originalItem = {
|
|
293
|
+
_id: '67fea241af24e570c032b319',
|
|
294
|
+
_updatedAt: '2025-06-18T20:21:00.922Z',
|
|
295
|
+
_createdAt: '2025-04-15T18:15:30.262Z',
|
|
296
|
+
name: "2pc Men's Suit",
|
|
297
|
+
description: null,
|
|
298
|
+
pieces: 2,
|
|
299
|
+
weight: 0,
|
|
300
|
+
properties: {
|
|
301
|
+
url: null,
|
|
302
|
+
color: 'rgba(178,232,239,1)',
|
|
303
|
+
label: {
|
|
304
|
+
backgroundColor: 'rgba(255,235,59,1)',
|
|
305
|
+
align: null,
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
sku: null,
|
|
309
|
+
hasInventory: false,
|
|
310
|
+
inventoryType: 'push',
|
|
311
|
+
quantity: 0,
|
|
312
|
+
tags: ['default'],
|
|
313
|
+
category: null,
|
|
314
|
+
__typename: 'Item',
|
|
315
|
+
modifiers: [],
|
|
316
|
+
priceLevels: [
|
|
317
|
+
{
|
|
318
|
+
value: 129,
|
|
319
|
+
tags: ['default'],
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
value: 15,
|
|
323
|
+
tags: ['default', 'vip'],
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
value: 10,
|
|
327
|
+
tags: ['default', 'rich'],
|
|
328
|
+
},
|
|
329
|
+
],
|
|
330
|
+
costLevels: [],
|
|
331
|
+
};
|
|
332
|
+
let result = pricingService.order.addItemModifier({
|
|
333
|
+
itemIndex: 0,
|
|
334
|
+
modifier: {
|
|
335
|
+
_id: '67fea241af24e570c032b33f',
|
|
336
|
+
attributes: ['department'],
|
|
337
|
+
name: 'Dry Cleaning',
|
|
338
|
+
group: 'Department',
|
|
339
|
+
tags: ['default'],
|
|
340
|
+
included: true,
|
|
341
|
+
direct: true,
|
|
342
|
+
code: 'D',
|
|
343
|
+
properties: {
|
|
344
|
+
group: null,
|
|
345
|
+
department: {
|
|
346
|
+
tagSize: 'small',
|
|
347
|
+
customerTagsExtend: ['vip'],
|
|
348
|
+
autoSplit: false,
|
|
349
|
+
splitUnit: 'quantity',
|
|
350
|
+
maxItems: '3',
|
|
351
|
+
},
|
|
352
|
+
url: null,
|
|
353
|
+
color: null,
|
|
354
|
+
label: {
|
|
355
|
+
backgroundColor: null,
|
|
356
|
+
align: null,
|
|
357
|
+
},
|
|
358
|
+
sort: null,
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
order,
|
|
362
|
+
force: true,
|
|
363
|
+
originalItem,
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
expect(result.items[0].price).toBe(15);
|
|
367
|
+
|
|
368
|
+
result = pricingService.order.removeItemModifier({
|
|
369
|
+
order: result,
|
|
370
|
+
modifier: result.items[0].modifiers[0],
|
|
371
|
+
itemIndex: 0,
|
|
372
|
+
originalItem,
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
expect(result.items[0].price).toBe(129);
|
|
376
|
+
});
|
|
239
377
|
});
|
|
@@ -52,17 +52,10 @@ describe('Modifier actions', () => {
|
|
|
52
52
|
modifiers: [],
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
const conditionsBag = [];
|
|
56
|
-
|
|
57
55
|
const updatedOrder = pricingService.order.addItemModifier({
|
|
58
56
|
order,
|
|
59
57
|
modifier,
|
|
60
58
|
itemIndex: 0,
|
|
61
|
-
onConditionsNotMet: bag => {
|
|
62
|
-
bag.forEach(condition => {
|
|
63
|
-
conditionsBag.push(condition);
|
|
64
|
-
});
|
|
65
|
-
},
|
|
66
59
|
});
|
|
67
60
|
|
|
68
61
|
let error = '';
|
|
@@ -70,17 +63,11 @@ describe('Modifier actions', () => {
|
|
|
70
63
|
order: { ...updatedOrder },
|
|
71
64
|
modifier,
|
|
72
65
|
itemIndex: 0,
|
|
73
|
-
onConditionsNotMet: bag => {
|
|
74
|
-
bag.forEach(condition => {
|
|
75
|
-
conditionsBag.push(condition);
|
|
76
|
-
});
|
|
77
|
-
},
|
|
78
66
|
onError: errorMessage => {
|
|
79
67
|
error = errorMessage;
|
|
80
68
|
},
|
|
81
69
|
});
|
|
82
70
|
|
|
83
|
-
expect(conditionsBag).toEqual([]);
|
|
84
71
|
expect(error).toEqual('');
|
|
85
72
|
|
|
86
73
|
expect(updatedOrder2.items[0].modifiers.length).toEqual(2);
|
|
@@ -110,17 +97,10 @@ describe('Modifier actions', () => {
|
|
|
110
97
|
modifiers: [],
|
|
111
98
|
});
|
|
112
99
|
|
|
113
|
-
const conditionsBag = [];
|
|
114
|
-
|
|
115
100
|
const updatedOrder = pricingService.order.addItemModifier({
|
|
116
101
|
order,
|
|
117
102
|
modifier,
|
|
118
103
|
itemIndex: 0,
|
|
119
|
-
onConditionsNotMet: bag => {
|
|
120
|
-
bag.forEach(condition => {
|
|
121
|
-
conditionsBag.push(condition);
|
|
122
|
-
});
|
|
123
|
-
},
|
|
124
104
|
});
|
|
125
105
|
|
|
126
106
|
let error = '';
|
|
@@ -128,17 +108,11 @@ describe('Modifier actions', () => {
|
|
|
128
108
|
order: { ...updatedOrder },
|
|
129
109
|
modifier,
|
|
130
110
|
itemIndex: 0,
|
|
131
|
-
onConditionsNotMet: bag => {
|
|
132
|
-
bag.forEach(condition => {
|
|
133
|
-
conditionsBag.push(condition);
|
|
134
|
-
});
|
|
135
|
-
},
|
|
136
111
|
onError: errorMessage => {
|
|
137
112
|
error = errorMessage;
|
|
138
113
|
},
|
|
139
114
|
});
|
|
140
115
|
|
|
141
|
-
expect(conditionsBag).toEqual([]);
|
|
142
116
|
expect(error).toEqual('modifier.has.reached.the.maximum.amount.of.applies');
|
|
143
117
|
expect(updatedOrder2).toEqual(updatedOrder);
|
|
144
118
|
});
|
|
@@ -165,17 +139,10 @@ describe('Modifier actions', () => {
|
|
|
165
139
|
properties: {},
|
|
166
140
|
});
|
|
167
141
|
|
|
168
|
-
const conditionsBag = [];
|
|
169
|
-
|
|
170
142
|
const updatedOrder = pricingService.order.addItemModifier({
|
|
171
143
|
order,
|
|
172
144
|
modifier,
|
|
173
145
|
itemIndex: 0,
|
|
174
|
-
onConditionsNotMet: bag => {
|
|
175
|
-
bag.forEach(condition => {
|
|
176
|
-
conditionsBag.push(condition);
|
|
177
|
-
});
|
|
178
|
-
},
|
|
179
146
|
});
|
|
180
147
|
|
|
181
148
|
let error = '';
|
|
@@ -183,17 +150,12 @@ describe('Modifier actions', () => {
|
|
|
183
150
|
order: { ...updatedOrder },
|
|
184
151
|
modifier,
|
|
185
152
|
itemIndex: 0,
|
|
186
|
-
|
|
187
|
-
bag.forEach(condition => {
|
|
188
|
-
conditionsBag.push(condition);
|
|
189
|
-
});
|
|
190
|
-
},
|
|
153
|
+
|
|
191
154
|
onError: errorMessage => {
|
|
192
155
|
error = errorMessage;
|
|
193
156
|
},
|
|
194
157
|
});
|
|
195
158
|
|
|
196
|
-
expect(conditionsBag).toEqual([]);
|
|
197
159
|
expect(error).toEqual('');
|
|
198
160
|
expect(updatedOrder2).toEqual(order);
|
|
199
161
|
});
|
|
@@ -902,17 +864,10 @@ describe('Modifier actions', () => {
|
|
|
902
864
|
modifiers: [],
|
|
903
865
|
});
|
|
904
866
|
|
|
905
|
-
const conditionsBag = [];
|
|
906
|
-
|
|
907
867
|
const updatedOrder = pricingService.order.addItemModifier({
|
|
908
868
|
order,
|
|
909
869
|
modifier,
|
|
910
870
|
itemIndex: 0,
|
|
911
|
-
onConditionsNotMet: bag => {
|
|
912
|
-
bag.forEach(condition => {
|
|
913
|
-
conditionsBag.push(condition);
|
|
914
|
-
});
|
|
915
|
-
},
|
|
916
871
|
});
|
|
917
872
|
|
|
918
873
|
let error = '';
|
|
@@ -920,17 +875,11 @@ describe('Modifier actions', () => {
|
|
|
920
875
|
order: { ...updatedOrder },
|
|
921
876
|
modifier,
|
|
922
877
|
itemIndex: 0,
|
|
923
|
-
onConditionsNotMet: bag => {
|
|
924
|
-
bag.forEach(condition => {
|
|
925
|
-
conditionsBag.push(condition);
|
|
926
|
-
});
|
|
927
|
-
},
|
|
928
878
|
onError: errorMessage => {
|
|
929
879
|
error = errorMessage;
|
|
930
880
|
},
|
|
931
881
|
});
|
|
932
882
|
|
|
933
|
-
expect(conditionsBag).toEqual([]);
|
|
934
883
|
expect(error).toEqual('modifier.has.reached.the.maximum.amount.of.applies');
|
|
935
884
|
expect(updatedOrder2.items[0].modifiers.length).toBe(1);
|
|
936
885
|
expect(updatedOrder2.items[0].modifiers).toMatchObject([
|
|
@@ -976,8 +925,6 @@ describe('Modifier actions', () => {
|
|
|
976
925
|
modifiers: [],
|
|
977
926
|
});
|
|
978
927
|
|
|
979
|
-
const conditionsBag = [];
|
|
980
|
-
|
|
981
928
|
let error = '';
|
|
982
929
|
let currentOrder = { ...order };
|
|
983
930
|
|
|
@@ -986,11 +933,7 @@ describe('Modifier actions', () => {
|
|
|
986
933
|
order: currentOrder,
|
|
987
934
|
modifier,
|
|
988
935
|
itemIndex: 0,
|
|
989
|
-
|
|
990
|
-
bag.forEach(condition => {
|
|
991
|
-
conditionsBag.push(condition);
|
|
992
|
-
});
|
|
993
|
-
},
|
|
936
|
+
|
|
994
937
|
// eslint-disable-next-line no-loop-func
|
|
995
938
|
onError: errorMessage => {
|
|
996
939
|
error = errorMessage;
|
|
@@ -998,7 +941,6 @@ describe('Modifier actions', () => {
|
|
|
998
941
|
});
|
|
999
942
|
}
|
|
1000
943
|
|
|
1001
|
-
expect(conditionsBag).toEqual([]);
|
|
1002
944
|
expect(error).toEqual('');
|
|
1003
945
|
|
|
1004
946
|
expect(currentOrder.items[0].modifiers.length).toBe(5);
|
|
@@ -1030,8 +972,6 @@ describe('Modifier actions', () => {
|
|
|
1030
972
|
modifiers: [],
|
|
1031
973
|
});
|
|
1032
974
|
|
|
1033
|
-
const conditionsBag = [];
|
|
1034
|
-
|
|
1035
975
|
let error = '';
|
|
1036
976
|
let currentOrder = { ...order };
|
|
1037
977
|
|
|
@@ -1040,11 +980,7 @@ describe('Modifier actions', () => {
|
|
|
1040
980
|
order: currentOrder,
|
|
1041
981
|
modifier,
|
|
1042
982
|
itemIndex: 0,
|
|
1043
|
-
|
|
1044
|
-
bag.forEach(condition => {
|
|
1045
|
-
conditionsBag.push(condition);
|
|
1046
|
-
});
|
|
1047
|
-
},
|
|
983
|
+
|
|
1048
984
|
// eslint-disable-next-line no-loop-func
|
|
1049
985
|
onError: errorMessage => {
|
|
1050
986
|
error = errorMessage;
|
|
@@ -1052,7 +988,6 @@ describe('Modifier actions', () => {
|
|
|
1052
988
|
});
|
|
1053
989
|
}
|
|
1054
990
|
|
|
1055
|
-
expect(conditionsBag).toEqual([]);
|
|
1056
991
|
expect(error).toEqual('');
|
|
1057
992
|
|
|
1058
993
|
const calculatedOrder = pricingService.order.calculate(currentOrder);
|
|
@@ -1085,8 +1020,6 @@ describe('Modifier actions', () => {
|
|
|
1085
1020
|
modifiers: [],
|
|
1086
1021
|
});
|
|
1087
1022
|
|
|
1088
|
-
const conditionsBag = [];
|
|
1089
|
-
|
|
1090
1023
|
let error = '';
|
|
1091
1024
|
let currentOrder = { ...order };
|
|
1092
1025
|
|
|
@@ -1095,11 +1028,6 @@ describe('Modifier actions', () => {
|
|
|
1095
1028
|
order: currentOrder,
|
|
1096
1029
|
modifier,
|
|
1097
1030
|
itemIndex: 0,
|
|
1098
|
-
onConditionsNotMet: bag => {
|
|
1099
|
-
bag.forEach(condition => {
|
|
1100
|
-
conditionsBag.push(condition);
|
|
1101
|
-
});
|
|
1102
|
-
},
|
|
1103
1031
|
// eslint-disable-next-line no-loop-func
|
|
1104
1032
|
onError: errorMessage => {
|
|
1105
1033
|
error = errorMessage;
|
|
@@ -1107,7 +1035,6 @@ describe('Modifier actions', () => {
|
|
|
1107
1035
|
});
|
|
1108
1036
|
}
|
|
1109
1037
|
|
|
1110
|
-
expect(conditionsBag).toEqual([]);
|
|
1111
1038
|
expect(error).toEqual('modifier.has.reached.the.maximum.amount.of.applies');
|
|
1112
1039
|
|
|
1113
1040
|
expect(currentOrder.items[0].modifiers.length).toBe(10);
|
|
@@ -1138,8 +1065,6 @@ describe('Modifier actions', () => {
|
|
|
1138
1065
|
modifiers: [],
|
|
1139
1066
|
});
|
|
1140
1067
|
|
|
1141
|
-
const conditionsBag = [];
|
|
1142
|
-
|
|
1143
1068
|
let error = '';
|
|
1144
1069
|
let currentOrder = { ...order };
|
|
1145
1070
|
|
|
@@ -1148,11 +1073,6 @@ describe('Modifier actions', () => {
|
|
|
1148
1073
|
order: currentOrder,
|
|
1149
1074
|
modifier,
|
|
1150
1075
|
itemIndex: 0,
|
|
1151
|
-
onConditionsNotMet: bag => {
|
|
1152
|
-
bag.forEach(condition => {
|
|
1153
|
-
conditionsBag.push(condition);
|
|
1154
|
-
});
|
|
1155
|
-
},
|
|
1156
1076
|
// eslint-disable-next-line no-loop-func
|
|
1157
1077
|
onError: errorMessage => {
|
|
1158
1078
|
error = errorMessage;
|
|
@@ -1160,7 +1080,6 @@ describe('Modifier actions', () => {
|
|
|
1160
1080
|
});
|
|
1161
1081
|
}
|
|
1162
1082
|
|
|
1163
|
-
expect(conditionsBag).toEqual([]);
|
|
1164
1083
|
expect(error).toEqual('');
|
|
1165
1084
|
|
|
1166
1085
|
expect(currentOrder.items[0].modifiers.length).toBe(5);
|
|
@@ -1191,8 +1110,6 @@ describe('Modifier actions', () => {
|
|
|
1191
1110
|
modifiers: [],
|
|
1192
1111
|
});
|
|
1193
1112
|
|
|
1194
|
-
const conditionsBag = [];
|
|
1195
|
-
|
|
1196
1113
|
let error = '';
|
|
1197
1114
|
let currentOrder = { ...order };
|
|
1198
1115
|
|
|
@@ -1201,11 +1118,7 @@ describe('Modifier actions', () => {
|
|
|
1201
1118
|
order: currentOrder,
|
|
1202
1119
|
modifier,
|
|
1203
1120
|
itemIndex: 0,
|
|
1204
|
-
|
|
1205
|
-
bag.forEach(condition => {
|
|
1206
|
-
conditionsBag.push(condition);
|
|
1207
|
-
});
|
|
1208
|
-
},
|
|
1121
|
+
|
|
1209
1122
|
// eslint-disable-next-line no-loop-func
|
|
1210
1123
|
onError: errorMessage => {
|
|
1211
1124
|
error = errorMessage;
|
|
@@ -1213,7 +1126,6 @@ describe('Modifier actions', () => {
|
|
|
1213
1126
|
});
|
|
1214
1127
|
}
|
|
1215
1128
|
|
|
1216
|
-
expect(conditionsBag).toEqual([]);
|
|
1217
1129
|
expect(error).toEqual('');
|
|
1218
1130
|
|
|
1219
1131
|
expect(currentOrder.items[0].modifiers.length).toBe(2);
|
|
@@ -1263,8 +1175,6 @@ describe('Modifier actions', () => {
|
|
|
1263
1175
|
modifiers: [],
|
|
1264
1176
|
});
|
|
1265
1177
|
|
|
1266
|
-
const conditionsBag = [];
|
|
1267
|
-
|
|
1268
1178
|
let error = '';
|
|
1269
1179
|
let currentOrder = { ...order };
|
|
1270
1180
|
|
|
@@ -1272,11 +1182,7 @@ describe('Modifier actions', () => {
|
|
|
1272
1182
|
order: currentOrder,
|
|
1273
1183
|
modifier,
|
|
1274
1184
|
itemIndex: 0,
|
|
1275
|
-
|
|
1276
|
-
bag.forEach(condition => {
|
|
1277
|
-
conditionsBag.push(condition);
|
|
1278
|
-
});
|
|
1279
|
-
},
|
|
1185
|
+
|
|
1280
1186
|
onError: errorMessage => {
|
|
1281
1187
|
error = errorMessage;
|
|
1282
1188
|
},
|
|
@@ -1286,11 +1192,7 @@ describe('Modifier actions', () => {
|
|
|
1286
1192
|
order: currentOrder,
|
|
1287
1193
|
modifier,
|
|
1288
1194
|
itemIndex: 1,
|
|
1289
|
-
|
|
1290
|
-
bag.forEach(condition => {
|
|
1291
|
-
conditionsBag.push(condition);
|
|
1292
|
-
});
|
|
1293
|
-
},
|
|
1195
|
+
|
|
1294
1196
|
onError: errorMessage => {
|
|
1295
1197
|
error = errorMessage;
|
|
1296
1198
|
},
|
|
@@ -1300,17 +1202,12 @@ describe('Modifier actions', () => {
|
|
|
1300
1202
|
order: currentOrder,
|
|
1301
1203
|
modifier,
|
|
1302
1204
|
itemIndex: 2,
|
|
1303
|
-
|
|
1304
|
-
bag.forEach(condition => {
|
|
1305
|
-
conditionsBag.push(condition);
|
|
1306
|
-
});
|
|
1307
|
-
},
|
|
1205
|
+
|
|
1308
1206
|
onError: errorMessage => {
|
|
1309
1207
|
error = errorMessage;
|
|
1310
1208
|
},
|
|
1311
1209
|
});
|
|
1312
1210
|
|
|
1313
|
-
expect(conditionsBag).toEqual([]);
|
|
1314
1211
|
expect(error).toEqual('');
|
|
1315
1212
|
expect(currentOrder.items[0].modifiers.length).toBe(1);
|
|
1316
1213
|
expect(currentOrder.items[1].modifiers.length).toBe(1);
|
|
@@ -1323,17 +1220,12 @@ describe('Modifier actions', () => {
|
|
|
1323
1220
|
order: currentOrder,
|
|
1324
1221
|
modifier,
|
|
1325
1222
|
itemIndex: 3,
|
|
1326
|
-
|
|
1327
|
-
bag.forEach(condition => {
|
|
1328
|
-
conditionsBag.push(condition);
|
|
1329
|
-
});
|
|
1330
|
-
},
|
|
1223
|
+
|
|
1331
1224
|
onError: errorMessage => {
|
|
1332
1225
|
error = errorMessage;
|
|
1333
1226
|
},
|
|
1334
1227
|
});
|
|
1335
1228
|
|
|
1336
|
-
expect(conditionsBag).toEqual([]);
|
|
1337
1229
|
expect(error).toEqual('modifier.has.reached.the.maximum.amount.of.applies');
|
|
1338
1230
|
expect(currentOrder.items[3].modifiers.length).toBe(0);
|
|
1339
1231
|
});
|
|
@@ -1760,17 +1652,10 @@ describe('Modifier actions', () => {
|
|
|
1760
1652
|
modifiers: [],
|
|
1761
1653
|
});
|
|
1762
1654
|
|
|
1763
|
-
const conditionsBag = [];
|
|
1764
|
-
|
|
1765
1655
|
const updatedOrder = pricingService.order.addItemModifier({
|
|
1766
1656
|
order,
|
|
1767
1657
|
modifier,
|
|
1768
1658
|
itemIndex: 0,
|
|
1769
|
-
onConditionsNotMet: bag => {
|
|
1770
|
-
bag.forEach(condition => {
|
|
1771
|
-
conditionsBag.push(condition);
|
|
1772
|
-
});
|
|
1773
|
-
},
|
|
1774
1659
|
});
|
|
1775
1660
|
|
|
1776
1661
|
let error = '';
|
|
@@ -1778,17 +1663,12 @@ describe('Modifier actions', () => {
|
|
|
1778
1663
|
order: { ...updatedOrder },
|
|
1779
1664
|
modifier,
|
|
1780
1665
|
itemIndex: 0,
|
|
1781
|
-
|
|
1782
|
-
bag.forEach(condition => {
|
|
1783
|
-
conditionsBag.push(condition);
|
|
1784
|
-
});
|
|
1785
|
-
},
|
|
1666
|
+
|
|
1786
1667
|
onError: errorMessage => {
|
|
1787
1668
|
error = errorMessage;
|
|
1788
1669
|
},
|
|
1789
1670
|
});
|
|
1790
1671
|
|
|
1791
|
-
expect(conditionsBag).toEqual([]);
|
|
1792
1672
|
expect(error).toEqual('');
|
|
1793
1673
|
|
|
1794
1674
|
expect(updatedOrder2.items[0].modifiers.length).toEqual(2);
|
|
@@ -1819,17 +1699,10 @@ describe('Modifier actions', () => {
|
|
|
1819
1699
|
modifiers: [],
|
|
1820
1700
|
});
|
|
1821
1701
|
|
|
1822
|
-
const conditionsBag = [];
|
|
1823
|
-
|
|
1824
1702
|
const updatedOrder = pricingService.order.addItemModifier({
|
|
1825
1703
|
order,
|
|
1826
1704
|
modifier,
|
|
1827
1705
|
itemIndex: 0,
|
|
1828
|
-
onConditionsNotMet: bag => {
|
|
1829
|
-
bag.forEach(condition => {
|
|
1830
|
-
conditionsBag.push(condition);
|
|
1831
|
-
});
|
|
1832
|
-
},
|
|
1833
1706
|
});
|
|
1834
1707
|
|
|
1835
1708
|
let error = '';
|
|
@@ -1837,17 +1710,12 @@ describe('Modifier actions', () => {
|
|
|
1837
1710
|
order: { ...updatedOrder },
|
|
1838
1711
|
modifier,
|
|
1839
1712
|
itemIndex: 0,
|
|
1840
|
-
|
|
1841
|
-
bag.forEach(condition => {
|
|
1842
|
-
conditionsBag.push(condition);
|
|
1843
|
-
});
|
|
1844
|
-
},
|
|
1713
|
+
|
|
1845
1714
|
onError: errorMessage => {
|
|
1846
1715
|
error = errorMessage;
|
|
1847
1716
|
},
|
|
1848
1717
|
});
|
|
1849
1718
|
|
|
1850
|
-
expect(conditionsBag).toEqual([]);
|
|
1851
1719
|
expect(error).toEqual('modifier.has.reached.the.maximum.amount.of.applies');
|
|
1852
1720
|
|
|
1853
1721
|
expect(updatedOrder2.items[0].modifiers.length).toEqual(1);
|