@zoxllc/shopify-checkout-extensions 0.0.8 → 0.1.0
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/CLAUDE.md +136 -0
- package/EXAMPLES.md +384 -0
- package/INTEGRATION.md +482 -0
- package/README.md +5 -1
- package/dist/common/AndSelector.d.ts +11 -0
- package/dist/common/AndSelector.d.ts.map +1 -0
- package/dist/common/AndSelector.js +30 -0
- package/dist/common/Campaign.d.ts +24 -0
- package/dist/common/Campaign.d.ts.map +1 -0
- package/dist/common/Campaign.js +41 -0
- package/dist/common/CampaignConfiguration.d.ts +10 -0
- package/dist/common/CampaignConfiguration.d.ts.map +1 -0
- package/dist/common/CampaignConfiguration.js +7 -0
- package/dist/common/CampaignFactory.d.ts +22 -0
- package/dist/common/CampaignFactory.d.ts.map +1 -0
- package/dist/common/CampaignFactory.js +95 -0
- package/dist/common/CartAmountQualifier.d.ts +22 -0
- package/dist/common/CartAmountQualifier.d.ts.map +1 -0
- package/dist/common/CartAmountQualifier.js +46 -0
- package/dist/common/CartHasItemQualifier.d.ts +21 -0
- package/dist/common/CartHasItemQualifier.d.ts.map +1 -0
- package/dist/common/CartHasItemQualifier.js +54 -0
- package/dist/common/CartQuantityQualifier.d.ts +22 -0
- package/dist/common/CartQuantityQualifier.d.ts.map +1 -0
- package/dist/common/CartQuantityQualifier.js +62 -0
- package/dist/common/ConfigSchema.d.ts +71 -0
- package/dist/common/ConfigSchema.d.ts.map +1 -0
- package/dist/common/ConfigSchema.js +69 -0
- package/dist/common/ConfigValidator.d.ts +29 -0
- package/dist/common/ConfigValidator.d.ts.map +1 -0
- package/dist/common/ConfigValidator.js +84 -0
- package/dist/common/CountryCodeQualifier.d.ts +15 -0
- package/dist/common/CountryCodeQualifier.d.ts.map +1 -0
- package/dist/common/CountryCodeQualifier.js +30 -0
- package/dist/common/CustomerEmailQualifier.d.ts +16 -0
- package/dist/common/CustomerEmailQualifier.d.ts.map +1 -0
- package/dist/common/CustomerEmailQualifier.js +52 -0
- package/dist/common/CustomerSubscriberQualifier.d.ts +18 -0
- package/dist/common/CustomerSubscriberQualifier.d.ts.map +1 -0
- package/dist/common/CustomerSubscriberQualifier.js +28 -0
- package/dist/common/CustomerTagQualifier.d.ts +16 -0
- package/dist/common/CustomerTagQualifier.d.ts.map +1 -0
- package/dist/common/CustomerTagQualifier.js +45 -0
- package/dist/common/DiscountCart.d.ts +23 -0
- package/dist/common/DiscountCart.d.ts.map +1 -0
- package/dist/common/DiscountCart.js +103 -0
- package/dist/common/DiscountInterface.d.ts +17 -0
- package/dist/common/DiscountInterface.d.ts.map +1 -0
- package/dist/common/DiscountInterface.js +2 -0
- package/dist/common/OrSelector.d.ts +11 -0
- package/dist/common/OrSelector.d.ts.map +1 -0
- package/dist/common/OrSelector.js +30 -0
- package/dist/common/PostCartAmountQualifier.d.ts +9 -0
- package/dist/common/PostCartAmountQualifier.d.ts.map +1 -0
- package/dist/common/PostCartAmountQualifier.js +17 -0
- package/dist/common/ProductHandleSelector.d.ts +8 -0
- package/dist/common/ProductHandleSelector.d.ts.map +1 -0
- package/dist/common/ProductHandleSelector.js +22 -0
- package/dist/common/ProductIdSelector.d.ts +8 -0
- package/dist/common/ProductIdSelector.d.ts.map +1 -0
- package/dist/common/ProductIdSelector.js +22 -0
- package/dist/common/ProductTagSelector.d.ts +10 -0
- package/dist/common/ProductTagSelector.d.ts.map +1 -0
- package/dist/common/ProductTagSelector.js +39 -0
- package/dist/common/ProductTypeSelector.d.ts +8 -0
- package/dist/common/ProductTypeSelector.d.ts.map +1 -0
- package/dist/common/ProductTypeSelector.js +25 -0
- package/dist/common/Qualifier.d.ts +30 -0
- package/dist/common/Qualifier.d.ts.map +1 -0
- package/dist/common/Qualifier.js +61 -0
- package/dist/common/SaleItemSelector.d.ts +11 -0
- package/dist/common/SaleItemSelector.d.ts.map +1 -0
- package/dist/common/SaleItemSelector.js +30 -0
- package/dist/common/Selector.d.ts +27 -0
- package/dist/common/Selector.d.ts.map +1 -0
- package/dist/common/Selector.js +51 -0
- package/dist/common/SubscriptionItemSelector.d.ts +7 -0
- package/dist/common/SubscriptionItemSelector.d.ts.map +1 -0
- package/dist/common/SubscriptionItemSelector.js +19 -0
- package/dist/form/CampaignForm.d.ts +1 -0
- package/dist/form/CampaignForm.d.ts.map +1 -0
- package/dist/form/CampaignForm.js +1 -0
- package/{src/index.ts → dist/index.d.ts} +22 -27
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +78 -0
- package/dist/lineItem/BuyXGetY.d.ts +18 -0
- package/dist/lineItem/BuyXGetY.d.ts.map +1 -0
- package/dist/lineItem/BuyXGetY.js +85 -0
- package/dist/lineItem/ConditionalDiscount.d.ts +14 -0
- package/dist/lineItem/ConditionalDiscount.d.ts.map +1 -0
- package/dist/lineItem/ConditionalDiscount.js +81 -0
- package/dist/lineItem/FixedItemDiscount.d.ts +9 -0
- package/dist/lineItem/FixedItemDiscount.d.ts.map +1 -0
- package/dist/lineItem/FixedItemDiscount.js +35 -0
- package/dist/lineItem/PercentageDiscount.d.ts +8 -0
- package/dist/lineItem/PercentageDiscount.d.ts.map +1 -0
- package/dist/lineItem/PercentageDiscount.js +32 -0
- package/dist/lineItem/api.d.ts +2026 -0
- package/dist/lineItem/api.d.ts.map +1 -0
- package/dist/lineItem/api.js +1157 -0
- package/dist/shipping/FixedDiscount.d.ts +8 -0
- package/dist/shipping/FixedDiscount.d.ts.map +1 -0
- package/dist/shipping/FixedDiscount.js +30 -0
- package/dist/shipping/RateNameSelector.d.ts +10 -0
- package/dist/shipping/RateNameSelector.d.ts.map +1 -0
- package/dist/shipping/RateNameSelector.js +45 -0
- package/dist/shipping/ShippingDiscount.d.ts +14 -0
- package/dist/shipping/ShippingDiscount.d.ts.map +1 -0
- package/dist/shipping/ShippingDiscount.js +48 -0
- package/dist/shipping/api.d.ts +2019 -0
- package/dist/shipping/api.d.ts.map +1 -0
- package/dist/shipping/api.js +1147 -0
- package/package.json +26 -7
- package/migrate.ts +0 -64
- package/src/common/AndSelector.ts +0 -42
- package/src/common/Campaign.ts +0 -70
- package/src/common/CampaignConfiguration.ts +0 -10
- package/src/common/CampaignFactory.ts +0 -233
- package/src/common/CartAmountQualifier.ts +0 -64
- package/src/common/CartHasItemQualifier.ts +0 -80
- package/src/common/CartQuantityQualifier.ts +0 -94
- package/src/common/CountryCodeQualifier.ts +0 -49
- package/src/common/CustomerEmailQualifier.ts +0 -67
- package/src/common/CustomerSubscriberQualifier.ts +0 -32
- package/src/common/CustomerTagQualifier.ts +0 -69
- package/src/common/DiscountCart.ts +0 -161
- package/src/common/DiscountInterface.ts +0 -26
- package/src/common/OrSelector.ts +0 -40
- package/src/common/PostCartAmountQualifier.ts +0 -21
- package/src/common/ProductHandleSelector.ts +0 -32
- package/src/common/ProductIdSelector.ts +0 -34
- package/src/common/ProductTagSelector.ts +0 -63
- package/src/common/ProductTypeSelector.ts +0 -40
- package/src/common/Qualifier.ts +0 -67
- package/src/common/SaleItemSelector.ts +0 -36
- package/src/common/Selector.ts +0 -66
- package/src/common/SubscriptionItemSelector.ts +0 -23
- package/src/lineItem/BuyXGetY.ts +0 -131
- package/src/lineItem/ConditionalDiscount.ts +0 -102
- package/src/lineItem/FixedItemDiscount.ts +0 -51
- package/src/lineItem/PercentageDiscount.ts +0 -44
- package/src/lineItem/api.ts +0 -2103
- package/src/shipping/FixedDiscount.ts +0 -37
- package/src/shipping/RateNameSelector.ts +0 -54
- package/src/shipping/ShippingDiscount.ts +0 -75
- package/src/shipping/api.ts +0 -2014
- package/tests/AndSelector.test.ts +0 -27
- package/tests/CartQuantityQualifier.test.ts +0 -381
- package/tests/CountryCodeQualifier.test.ts +0 -55
- package/tests/CustomerSubscriberQualifier.test.ts +0 -101
- package/tests/CustomerTagQualifier.test.ts +0 -71
- package/tests/DiscountCart.test.ts +0 -115
- package/tests/OrSelector.test.ts +0 -27
- package/tests/ProductIdSelector.test.ts +0 -83
- package/tests/ProductTagSelector.test.ts +0 -75
- package/tests/Qualifier.test.ts +0 -193
- package/tests/RateNameSelector.test.ts +0 -107
- package/tests/SaleItemSelector.test.ts +0 -113
- package/tests/Selector.test.ts +0 -83
- package/tests/ShippingDiscount.test.ts +0 -147
- package/tsconfig.json +0 -25
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { AndSelector } from '../src/common/AndSelector';
|
|
3
|
-
import { CartLine } from '../src/lineItem/api';
|
|
4
|
-
import {
|
|
5
|
-
MockFalseyQualifier,
|
|
6
|
-
MockTruthyQualifier,
|
|
7
|
-
} from './Qualifier.test';
|
|
8
|
-
|
|
9
|
-
describe('AndSelector', () => {
|
|
10
|
-
it('Returns true if all conditions are met', () => {
|
|
11
|
-
const selector = new AndSelector([
|
|
12
|
-
new MockTruthyQualifier(),
|
|
13
|
-
new MockTruthyQualifier(),
|
|
14
|
-
]);
|
|
15
|
-
|
|
16
|
-
expect(selector.match({} as CartLine)).toBeTruthy();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('Returns false if any conditions are not met', () => {
|
|
20
|
-
const selector = new AndSelector([
|
|
21
|
-
new MockTruthyQualifier(),
|
|
22
|
-
new MockFalseyQualifier(),
|
|
23
|
-
]);
|
|
24
|
-
|
|
25
|
-
expect(selector.match({} as CartLine)).toBeFalsy();
|
|
26
|
-
});
|
|
27
|
-
});
|
|
@@ -1,381 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { DiscountCart } from '../src/common/DiscountCart';
|
|
3
|
-
import { RunInput } from '../src/lineItem/api';
|
|
4
|
-
import _ from 'lodash';
|
|
5
|
-
import { NumericalComparisonType } from '../src/common/Qualifier';
|
|
6
|
-
import {
|
|
7
|
-
CartQuantityBehavior,
|
|
8
|
-
CartQuantityQualifier,
|
|
9
|
-
} from '../src/common/CartQuantityQualifier';
|
|
10
|
-
|
|
11
|
-
describe('CartQuantityQualifier', () => {
|
|
12
|
-
it('calculates :CART and :EQUAL_TO correctly', () => {
|
|
13
|
-
qualifier = new CartQuantityQualifier(
|
|
14
|
-
CartQuantityBehavior.CART,
|
|
15
|
-
NumericalComparisonType.EQUAL_TO,
|
|
16
|
-
14
|
|
17
|
-
);
|
|
18
|
-
matchResult = qualifier.match(cart);
|
|
19
|
-
expect(matchResult).toBe(true);
|
|
20
|
-
|
|
21
|
-
qualifier = new CartQuantityQualifier(
|
|
22
|
-
CartQuantityBehavior.CART,
|
|
23
|
-
NumericalComparisonType.EQUAL_TO,
|
|
24
|
-
10
|
|
25
|
-
);
|
|
26
|
-
matchResult = qualifier.match(cart);
|
|
27
|
-
expect(matchResult).toBe(false);
|
|
28
|
-
|
|
29
|
-
qualifier = new CartQuantityQualifier(
|
|
30
|
-
CartQuantityBehavior.CART,
|
|
31
|
-
NumericalComparisonType.EQUAL_TO,
|
|
32
|
-
100
|
|
33
|
-
);
|
|
34
|
-
matchResult = qualifier.match(cart);
|
|
35
|
-
expect(matchResult).toBe(false);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('calculates :CART and :LESS_THAN correctly', () => {
|
|
39
|
-
qualifier = new CartQuantityQualifier(
|
|
40
|
-
CartQuantityBehavior.CART,
|
|
41
|
-
NumericalComparisonType.LESS_THAN,
|
|
42
|
-
14
|
|
43
|
-
);
|
|
44
|
-
matchResult = qualifier.match(cart);
|
|
45
|
-
expect(matchResult).toBe(false);
|
|
46
|
-
|
|
47
|
-
qualifier = new CartQuantityQualifier(
|
|
48
|
-
CartQuantityBehavior.CART,
|
|
49
|
-
NumericalComparisonType.LESS_THAN,
|
|
50
|
-
13
|
|
51
|
-
);
|
|
52
|
-
matchResult = qualifier.match(cart);
|
|
53
|
-
expect(matchResult).toBe(false);
|
|
54
|
-
|
|
55
|
-
qualifier = new CartQuantityQualifier(
|
|
56
|
-
CartQuantityBehavior.CART,
|
|
57
|
-
NumericalComparisonType.LESS_THAN,
|
|
58
|
-
15
|
|
59
|
-
);
|
|
60
|
-
matchResult = qualifier.match(cart);
|
|
61
|
-
expect(matchResult).toBe(true);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('calculates :CART and :LESS_THAN_OR_EQUAL correctly', () => {
|
|
65
|
-
qualifier = new CartQuantityQualifier(
|
|
66
|
-
CartQuantityBehavior.CART,
|
|
67
|
-
NumericalComparisonType.LESS_THAN_OR_EQUAL,
|
|
68
|
-
14
|
|
69
|
-
);
|
|
70
|
-
matchResult = qualifier.match(cart);
|
|
71
|
-
expect(matchResult).toBe(true);
|
|
72
|
-
|
|
73
|
-
qualifier = new CartQuantityQualifier(
|
|
74
|
-
CartQuantityBehavior.CART,
|
|
75
|
-
NumericalComparisonType.LESS_THAN_OR_EQUAL,
|
|
76
|
-
13
|
|
77
|
-
);
|
|
78
|
-
matchResult = qualifier.match(cart);
|
|
79
|
-
expect(matchResult).toBe(false);
|
|
80
|
-
|
|
81
|
-
qualifier = new CartQuantityQualifier(
|
|
82
|
-
CartQuantityBehavior.CART,
|
|
83
|
-
NumericalComparisonType.LESS_THAN_OR_EQUAL,
|
|
84
|
-
15
|
|
85
|
-
);
|
|
86
|
-
matchResult = qualifier.match(cart);
|
|
87
|
-
expect(matchResult).toBe(true);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('calculates :CART and :GREATER_THAN correctly', () => {
|
|
91
|
-
qualifier = new CartQuantityQualifier(
|
|
92
|
-
CartQuantityBehavior.CART,
|
|
93
|
-
NumericalComparisonType.GREATER_THAN,
|
|
94
|
-
14
|
|
95
|
-
);
|
|
96
|
-
matchResult = qualifier.match(cart);
|
|
97
|
-
expect(matchResult).toBe(false);
|
|
98
|
-
|
|
99
|
-
qualifier = new CartQuantityQualifier(
|
|
100
|
-
CartQuantityBehavior.CART,
|
|
101
|
-
NumericalComparisonType.GREATER_THAN,
|
|
102
|
-
13
|
|
103
|
-
);
|
|
104
|
-
matchResult = qualifier.match(cart);
|
|
105
|
-
expect(matchResult).toBe(true);
|
|
106
|
-
|
|
107
|
-
qualifier = new CartQuantityQualifier(
|
|
108
|
-
CartQuantityBehavior.CART,
|
|
109
|
-
NumericalComparisonType.GREATER_THAN,
|
|
110
|
-
15
|
|
111
|
-
);
|
|
112
|
-
matchResult = qualifier.match(cart);
|
|
113
|
-
expect(matchResult).toBe(false);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('calculates :CART and :GREATER_THAN_OR_EQUAL correctly', () => {
|
|
117
|
-
qualifier = new CartQuantityQualifier(
|
|
118
|
-
CartQuantityBehavior.CART,
|
|
119
|
-
NumericalComparisonType.GREATER_THAN_OR_EQUAL,
|
|
120
|
-
14
|
|
121
|
-
);
|
|
122
|
-
matchResult = qualifier.match(cart);
|
|
123
|
-
expect(matchResult).toBe(true);
|
|
124
|
-
|
|
125
|
-
qualifier = new CartQuantityQualifier(
|
|
126
|
-
CartQuantityBehavior.CART,
|
|
127
|
-
NumericalComparisonType.GREATER_THAN_OR_EQUAL,
|
|
128
|
-
13
|
|
129
|
-
);
|
|
130
|
-
matchResult = qualifier.match(cart);
|
|
131
|
-
expect(matchResult).toBe(true);
|
|
132
|
-
|
|
133
|
-
qualifier = new CartQuantityQualifier(
|
|
134
|
-
CartQuantityBehavior.CART,
|
|
135
|
-
NumericalComparisonType.GREATER_THAN_OR_EQUAL,
|
|
136
|
-
15
|
|
137
|
-
);
|
|
138
|
-
matchResult = qualifier.match(cart);
|
|
139
|
-
expect(matchResult).toBe(false);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('calculates :ITEM and :EQUAL_TO correctly', () => {
|
|
143
|
-
qualifier = new CartQuantityQualifier(
|
|
144
|
-
CartQuantityBehavior.ITEM,
|
|
145
|
-
NumericalComparisonType.EQUAL_TO,
|
|
146
|
-
14
|
|
147
|
-
);
|
|
148
|
-
matchResult = qualifier.match(cart);
|
|
149
|
-
expect(matchResult).toBe(true);
|
|
150
|
-
|
|
151
|
-
qualifier = new CartQuantityQualifier(
|
|
152
|
-
CartQuantityBehavior.ITEM,
|
|
153
|
-
NumericalComparisonType.EQUAL_TO,
|
|
154
|
-
10
|
|
155
|
-
);
|
|
156
|
-
matchResult = qualifier.match(cart);
|
|
157
|
-
expect(matchResult).toBe(false);
|
|
158
|
-
|
|
159
|
-
qualifier = new CartQuantityQualifier(
|
|
160
|
-
CartQuantityBehavior.ITEM,
|
|
161
|
-
NumericalComparisonType.EQUAL_TO,
|
|
162
|
-
100
|
|
163
|
-
);
|
|
164
|
-
matchResult = qualifier.match(cart);
|
|
165
|
-
expect(matchResult).toBe(false);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it('calculates :ITEM and :LESS_THAN correctly', () => {
|
|
169
|
-
qualifier = new CartQuantityQualifier(
|
|
170
|
-
CartQuantityBehavior.ITEM,
|
|
171
|
-
NumericalComparisonType.LESS_THAN,
|
|
172
|
-
14
|
|
173
|
-
);
|
|
174
|
-
matchResult = qualifier.match(cart);
|
|
175
|
-
expect(matchResult).toBe(false);
|
|
176
|
-
|
|
177
|
-
qualifier = new CartQuantityQualifier(
|
|
178
|
-
CartQuantityBehavior.ITEM,
|
|
179
|
-
NumericalComparisonType.LESS_THAN,
|
|
180
|
-
13
|
|
181
|
-
);
|
|
182
|
-
matchResult = qualifier.match(cart);
|
|
183
|
-
expect(matchResult).toBe(false);
|
|
184
|
-
|
|
185
|
-
qualifier = new CartQuantityQualifier(
|
|
186
|
-
CartQuantityBehavior.ITEM,
|
|
187
|
-
NumericalComparisonType.LESS_THAN,
|
|
188
|
-
15
|
|
189
|
-
);
|
|
190
|
-
matchResult = qualifier.match(cart);
|
|
191
|
-
expect(matchResult).toBe(true);
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
it('calculates :ITEM and :LESS_THAN_OR_EQUAL correctly', () => {
|
|
195
|
-
qualifier = new CartQuantityQualifier(
|
|
196
|
-
CartQuantityBehavior.ITEM,
|
|
197
|
-
NumericalComparisonType.LESS_THAN_OR_EQUAL,
|
|
198
|
-
14
|
|
199
|
-
);
|
|
200
|
-
matchResult = qualifier.match(cart);
|
|
201
|
-
expect(matchResult).toBe(true);
|
|
202
|
-
|
|
203
|
-
qualifier = new CartQuantityQualifier(
|
|
204
|
-
CartQuantityBehavior.ITEM,
|
|
205
|
-
NumericalComparisonType.LESS_THAN_OR_EQUAL,
|
|
206
|
-
13
|
|
207
|
-
);
|
|
208
|
-
matchResult = qualifier.match(cart);
|
|
209
|
-
expect(matchResult).toBe(false);
|
|
210
|
-
|
|
211
|
-
qualifier = new CartQuantityQualifier(
|
|
212
|
-
CartQuantityBehavior.ITEM,
|
|
213
|
-
NumericalComparisonType.LESS_THAN_OR_EQUAL,
|
|
214
|
-
15
|
|
215
|
-
);
|
|
216
|
-
matchResult = qualifier.match(cart);
|
|
217
|
-
expect(matchResult).toBe(true);
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
it('calculates :ITEM and :GREATER_THAN correctly', () => {
|
|
221
|
-
qualifier = new CartQuantityQualifier(
|
|
222
|
-
CartQuantityBehavior.ITEM,
|
|
223
|
-
NumericalComparisonType.GREATER_THAN,
|
|
224
|
-
14
|
|
225
|
-
);
|
|
226
|
-
matchResult = qualifier.match(cart);
|
|
227
|
-
expect(matchResult).toBe(false);
|
|
228
|
-
|
|
229
|
-
qualifier = new CartQuantityQualifier(
|
|
230
|
-
CartQuantityBehavior.ITEM,
|
|
231
|
-
NumericalComparisonType.GREATER_THAN,
|
|
232
|
-
13
|
|
233
|
-
);
|
|
234
|
-
matchResult = qualifier.match(cart);
|
|
235
|
-
expect(matchResult).toBe(true);
|
|
236
|
-
|
|
237
|
-
qualifier = new CartQuantityQualifier(
|
|
238
|
-
CartQuantityBehavior.ITEM,
|
|
239
|
-
NumericalComparisonType.GREATER_THAN,
|
|
240
|
-
15
|
|
241
|
-
);
|
|
242
|
-
matchResult = qualifier.match(cart);
|
|
243
|
-
expect(matchResult).toBe(false);
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
it('calculates :ITEM and :GREATER_THAN_OR_EQUAL correctly', () => {
|
|
247
|
-
qualifier = new CartQuantityQualifier(
|
|
248
|
-
CartQuantityBehavior.ITEM,
|
|
249
|
-
NumericalComparisonType.GREATER_THAN_OR_EQUAL,
|
|
250
|
-
14
|
|
251
|
-
);
|
|
252
|
-
matchResult = qualifier.match(cart);
|
|
253
|
-
expect(matchResult).toBe(true);
|
|
254
|
-
|
|
255
|
-
qualifier = new CartQuantityQualifier(
|
|
256
|
-
CartQuantityBehavior.ITEM,
|
|
257
|
-
NumericalComparisonType.GREATER_THAN_OR_EQUAL,
|
|
258
|
-
13
|
|
259
|
-
);
|
|
260
|
-
matchResult = qualifier.match(cart);
|
|
261
|
-
expect(matchResult).toBe(true);
|
|
262
|
-
|
|
263
|
-
qualifier = new CartQuantityQualifier(
|
|
264
|
-
CartQuantityBehavior.ITEM,
|
|
265
|
-
NumericalComparisonType.GREATER_THAN_OR_EQUAL,
|
|
266
|
-
15
|
|
267
|
-
);
|
|
268
|
-
matchResult = qualifier.match(cart);
|
|
269
|
-
expect(matchResult).toBe(false);
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
const withSubscription: RunInput['cart'] = {
|
|
273
|
-
__typename: 'Cart',
|
|
274
|
-
cost: {
|
|
275
|
-
subtotalAmount: {
|
|
276
|
-
amount: '112.0',
|
|
277
|
-
},
|
|
278
|
-
totalAmount: {
|
|
279
|
-
amount: '112.0',
|
|
280
|
-
},
|
|
281
|
-
},
|
|
282
|
-
lines: [
|
|
283
|
-
{
|
|
284
|
-
cost: {
|
|
285
|
-
amountPerQuantity: {
|
|
286
|
-
amount: '8.0',
|
|
287
|
-
},
|
|
288
|
-
subtotalAmount: {
|
|
289
|
-
amount: '64.0',
|
|
290
|
-
},
|
|
291
|
-
totalAmount: {
|
|
292
|
-
amount: '64.0',
|
|
293
|
-
},
|
|
294
|
-
compareAtAmountPerQuantity: null,
|
|
295
|
-
},
|
|
296
|
-
quantity: 8,
|
|
297
|
-
merchandise: {
|
|
298
|
-
__typename: 'ProductVariant',
|
|
299
|
-
id: 'gid://shopify/ProductVariant/Single',
|
|
300
|
-
product: {
|
|
301
|
-
id: 'gid://shopify/Product/Single',
|
|
302
|
-
productType: 'Wristband - Single',
|
|
303
|
-
hasTags: [
|
|
304
|
-
{
|
|
305
|
-
tag: 'meta-exclude-gift',
|
|
306
|
-
hasTag: false,
|
|
307
|
-
},
|
|
308
|
-
{
|
|
309
|
-
tag: 'mystery-3-pack',
|
|
310
|
-
hasTag: false,
|
|
311
|
-
},
|
|
312
|
-
],
|
|
313
|
-
},
|
|
314
|
-
},
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
cost: {
|
|
318
|
-
amountPerQuantity: {
|
|
319
|
-
amount: '8.0',
|
|
320
|
-
},
|
|
321
|
-
subtotalAmount: {
|
|
322
|
-
amount: '48.0',
|
|
323
|
-
},
|
|
324
|
-
totalAmount: {
|
|
325
|
-
amount: '48.0',
|
|
326
|
-
},
|
|
327
|
-
compareAtAmountPerQuantity: null,
|
|
328
|
-
},
|
|
329
|
-
quantity: 6,
|
|
330
|
-
merchandise: {
|
|
331
|
-
__typename: 'ProductVariant',
|
|
332
|
-
id: 'gid://shopify/ProductVariant/Strap',
|
|
333
|
-
product: {
|
|
334
|
-
id: 'gid://shopify/Product/Strap',
|
|
335
|
-
productType: 'Wristband - Strap',
|
|
336
|
-
hasTags: [
|
|
337
|
-
{
|
|
338
|
-
tag: 'meta-exclude-gift',
|
|
339
|
-
hasTag: false,
|
|
340
|
-
},
|
|
341
|
-
{
|
|
342
|
-
tag: 'mystery-3-pack',
|
|
343
|
-
hasTag: false,
|
|
344
|
-
},
|
|
345
|
-
],
|
|
346
|
-
},
|
|
347
|
-
},
|
|
348
|
-
},
|
|
349
|
-
],
|
|
350
|
-
buyerIdentity: {
|
|
351
|
-
customer: {
|
|
352
|
-
isActiveSubscriber: true,
|
|
353
|
-
hasTags: [
|
|
354
|
-
{
|
|
355
|
-
tag: 'Active product subscription',
|
|
356
|
-
hasTag: true,
|
|
357
|
-
},
|
|
358
|
-
],
|
|
359
|
-
},
|
|
360
|
-
},
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
const withoutSubscription = _.cloneDeep(withSubscription);
|
|
364
|
-
_.merge(withoutSubscription, {
|
|
365
|
-
buyerIdentity: {
|
|
366
|
-
customer: {
|
|
367
|
-
isActiveSubscriber: false,
|
|
368
|
-
hasTags: [
|
|
369
|
-
{
|
|
370
|
-
hasTag: false,
|
|
371
|
-
tag: 'Active product subscription',
|
|
372
|
-
},
|
|
373
|
-
],
|
|
374
|
-
},
|
|
375
|
-
},
|
|
376
|
-
} as RunInput['cart']);
|
|
377
|
-
|
|
378
|
-
const cart = new DiscountCart(withSubscription);
|
|
379
|
-
let qualifier: CartQuantityQualifier;
|
|
380
|
-
let matchResult: boolean;
|
|
381
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import _ from 'lodash';
|
|
3
|
-
import { CountryCodeQualifier } from '../src/common/CountryCodeQualifier';
|
|
4
|
-
import { QualifierMatchType } from '../src/common/Qualifier';
|
|
5
|
-
import { DiscountCart } from '../src/common/DiscountCart';
|
|
6
|
-
|
|
7
|
-
describe('CountryCodeQualifier', () => {
|
|
8
|
-
it('is true when it matches one of', () => {
|
|
9
|
-
const qualifier = new CountryCodeQualifier(
|
|
10
|
-
QualifierMatchType.DOES,
|
|
11
|
-
['UK', 'AR', 'CA', 'US']
|
|
12
|
-
);
|
|
13
|
-
const result = qualifier.match(discountCart);
|
|
14
|
-
expect(result).toEqual(true);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('is false when subject not found when expected', () => {
|
|
18
|
-
const qualifier = new CountryCodeQualifier(
|
|
19
|
-
QualifierMatchType.DOES,
|
|
20
|
-
['UK', 'AR', 'CA', 'BR']
|
|
21
|
-
);
|
|
22
|
-
const result = qualifier.match(discountCart);
|
|
23
|
-
expect(result).toEqual(false);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('is true when it does not exist', () => {
|
|
27
|
-
const qualifier = new CountryCodeQualifier(
|
|
28
|
-
QualifierMatchType.DOES_NOT,
|
|
29
|
-
['UK', 'CA']
|
|
30
|
-
);
|
|
31
|
-
const result = qualifier.match(discountCart);
|
|
32
|
-
expect(result).toEqual(true);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('is false when it does exist and was expected not to', () => {
|
|
36
|
-
const qualifier = new CountryCodeQualifier(
|
|
37
|
-
QualifierMatchType.DOES_NOT,
|
|
38
|
-
['CA', 'AR', 'US', 'BR']
|
|
39
|
-
);
|
|
40
|
-
const result = qualifier.match(discountCart);
|
|
41
|
-
expect(result).toEqual(false);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const discountCart = {
|
|
45
|
-
cart: {
|
|
46
|
-
deliveryGroups: [
|
|
47
|
-
{
|
|
48
|
-
deliveryAddress: {
|
|
49
|
-
countryCode: 'US',
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
},
|
|
54
|
-
} as DiscountCart;
|
|
55
|
-
});
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { DiscountCart } from '../src/common/DiscountCart';
|
|
3
|
-
import { RunInput } from '../src/lineItem/api';
|
|
4
|
-
import _ from 'lodash';
|
|
5
|
-
import { CustomerSubscriberQualifier } from '../src/common/CustomerSubscriberQualifier';
|
|
6
|
-
import { QualifierMatchType } from '../src/common/Qualifier';
|
|
7
|
-
|
|
8
|
-
describe('CustomerSubscriberQualifier', () => {
|
|
9
|
-
it('is true when a customer contains a subscription', () => {
|
|
10
|
-
const cart = new DiscountCart(withSubscription);
|
|
11
|
-
|
|
12
|
-
const qualifier = new CustomerSubscriberQualifier(
|
|
13
|
-
QualifierMatchType.DOES
|
|
14
|
-
);
|
|
15
|
-
const matchResult = qualifier.match(cart);
|
|
16
|
-
expect(matchResult).toEqual(true);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('is true when a customer does NOT contain an active subscription', () => {
|
|
20
|
-
const cart = new DiscountCart(withoutSubscription);
|
|
21
|
-
|
|
22
|
-
const qualifier = new CustomerSubscriberQualifier(
|
|
23
|
-
QualifierMatchType.DOES_NOT
|
|
24
|
-
);
|
|
25
|
-
const matchResult = qualifier.match(cart);
|
|
26
|
-
expect(matchResult).toEqual(true);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const withSubscription: RunInput['cart'] = {
|
|
30
|
-
__typename: 'Cart',
|
|
31
|
-
cost: {
|
|
32
|
-
subtotalAmount: {
|
|
33
|
-
amount: '164.0',
|
|
34
|
-
},
|
|
35
|
-
totalAmount: {
|
|
36
|
-
amount: '164.0',
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
lines: [
|
|
40
|
-
{
|
|
41
|
-
cost: {
|
|
42
|
-
amountPerQuantity: {
|
|
43
|
-
amount: '8.0',
|
|
44
|
-
},
|
|
45
|
-
subtotalAmount: {
|
|
46
|
-
amount: '64.0',
|
|
47
|
-
},
|
|
48
|
-
totalAmount: {
|
|
49
|
-
amount: '64.0',
|
|
50
|
-
},
|
|
51
|
-
compareAtAmountPerQuantity: null,
|
|
52
|
-
},
|
|
53
|
-
quantity: 8,
|
|
54
|
-
merchandise: {
|
|
55
|
-
__typename: 'ProductVariant',
|
|
56
|
-
id: 'gid://shopify/ProductVariant/43900890579178',
|
|
57
|
-
product: {
|
|
58
|
-
id: 'gid://shopify/Product/8069766840554',
|
|
59
|
-
productType: 'Wristband - Single',
|
|
60
|
-
hasTags: [
|
|
61
|
-
{
|
|
62
|
-
tag: 'meta-exclude-gift',
|
|
63
|
-
hasTag: false,
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
tag: 'mystery-3-pack',
|
|
67
|
-
hasTag: false,
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
buyerIdentity: {
|
|
75
|
-
customer: {
|
|
76
|
-
isActiveSubscriber: true,
|
|
77
|
-
hasTags: [
|
|
78
|
-
{
|
|
79
|
-
tag: 'Active product subscription',
|
|
80
|
-
hasTag: true,
|
|
81
|
-
},
|
|
82
|
-
],
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const withoutSubscription = _.cloneDeep(withSubscription);
|
|
88
|
-
_.merge(withoutSubscription, {
|
|
89
|
-
buyerIdentity: {
|
|
90
|
-
customer: {
|
|
91
|
-
isActiveSubscriber: false,
|
|
92
|
-
hasTags: [
|
|
93
|
-
{
|
|
94
|
-
hasTag: false,
|
|
95
|
-
tag: 'Active product subscription',
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
} as RunInput['cart']);
|
|
101
|
-
});
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import _ from 'lodash';
|
|
3
|
-
import { CustomerTagQualifier } from '../src/common/CustomerTagQualifier';
|
|
4
|
-
import {
|
|
5
|
-
QualifierMatchType,
|
|
6
|
-
StringComparisonType,
|
|
7
|
-
} from '../src/common/Qualifier';
|
|
8
|
-
import { DiscountCart } from '../src/common/DiscountCart';
|
|
9
|
-
|
|
10
|
-
describe('CustomerTagQualifier', () => {
|
|
11
|
-
it('is true when it matches one of', () => {
|
|
12
|
-
const qualifier = new CustomerTagQualifier(
|
|
13
|
-
QualifierMatchType.DOES,
|
|
14
|
-
StringComparisonType.MATCH,
|
|
15
|
-
[
|
|
16
|
-
'tag1',
|
|
17
|
-
'tag2',
|
|
18
|
-
'Active product subscription',
|
|
19
|
-
'TAG4',
|
|
20
|
-
]
|
|
21
|
-
);
|
|
22
|
-
const result = qualifier.match(discountCart);
|
|
23
|
-
expect(result).toEqual(true);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('is false when it does NOT match one of', () => {
|
|
27
|
-
const qualifier = new CustomerTagQualifier(
|
|
28
|
-
QualifierMatchType.DOES,
|
|
29
|
-
StringComparisonType.MATCH,
|
|
30
|
-
['tag6', 'tag7', 'tag8', 'tag9']
|
|
31
|
-
);
|
|
32
|
-
const result = qualifier.match(discountCart);
|
|
33
|
-
expect(result).toEqual(false);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('is true when it contains one of', () => {
|
|
37
|
-
const qualifier = new CustomerTagQualifier(
|
|
38
|
-
QualifierMatchType.DOES,
|
|
39
|
-
StringComparisonType.CONTAINS,
|
|
40
|
-
['ag', 'product']
|
|
41
|
-
);
|
|
42
|
-
const result = qualifier.match(discountCart);
|
|
43
|
-
expect(result).toEqual(true);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('is false when it does NOT contain one of', () => {
|
|
47
|
-
const qualifier = new CustomerTagQualifier(
|
|
48
|
-
QualifierMatchType.DOES,
|
|
49
|
-
StringComparisonType.CONTAINS,
|
|
50
|
-
['sandwich', 'choir']
|
|
51
|
-
);
|
|
52
|
-
const result = qualifier.match(discountCart);
|
|
53
|
-
expect(result).toEqual(false);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const discountCart = {
|
|
57
|
-
cart: {
|
|
58
|
-
buyerIdentity: {
|
|
59
|
-
customer: {
|
|
60
|
-
hasTags: [
|
|
61
|
-
{
|
|
62
|
-
tag: 'Active product subscription',
|
|
63
|
-
hasTag: true,
|
|
64
|
-
},
|
|
65
|
-
{ tag: 'dev', hasTag: false },
|
|
66
|
-
],
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
} as DiscountCart;
|
|
71
|
-
});
|