@daffodil/cart 0.94.1 → 0.95.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.
Files changed (43) hide show
  1. package/fesm2022/daffodil-cart-driver-in-memory.mjs +1618 -1198
  2. package/fesm2022/daffodil-cart-driver-in-memory.mjs.map +1 -1
  3. package/fesm2022/daffodil-cart-driver-magento-2.4.7-testing.mjs +546 -0
  4. package/fesm2022/daffodil-cart-driver-magento-2.4.7-testing.mjs.map +1 -0
  5. package/fesm2022/daffodil-cart-driver-magento-2.4.7.mjs +2607 -0
  6. package/fesm2022/daffodil-cart-driver-magento-2.4.7.mjs.map +1 -0
  7. package/fesm2022/daffodil-cart-driver-magento-auto-testing.mjs +7 -0
  8. package/fesm2022/daffodil-cart-driver-magento-auto-testing.mjs.map +1 -0
  9. package/fesm2022/daffodil-cart-driver-magento-auto.mjs +7 -0
  10. package/fesm2022/daffodil-cart-driver-magento-auto.mjs.map +1 -0
  11. package/fesm2022/daffodil-cart-driver-testing.mjs +553 -335
  12. package/fesm2022/daffodil-cart-driver-testing.mjs.map +1 -1
  13. package/fesm2022/daffodil-cart-driver.mjs +167 -292
  14. package/fesm2022/daffodil-cart-driver.mjs.map +1 -1
  15. package/fesm2022/daffodil-cart-routing.mjs +741 -542
  16. package/fesm2022/daffodil-cart-routing.mjs.map +1 -1
  17. package/fesm2022/daffodil-cart-state-testing.mjs +288 -193
  18. package/fesm2022/daffodil-cart-state-testing.mjs.map +1 -1
  19. package/fesm2022/daffodil-cart-state.mjs +2571 -2800
  20. package/fesm2022/daffodil-cart-state.mjs.map +1 -1
  21. package/fesm2022/daffodil-cart-testing.mjs +542 -357
  22. package/fesm2022/daffodil-cart-testing.mjs.map +1 -1
  23. package/fesm2022/daffodil-cart.mjs +131 -200
  24. package/fesm2022/daffodil-cart.mjs.map +1 -1
  25. package/package.json +1 -1
  26. package/types/daffodil-cart-driver-in-memory.d.ts +273 -292
  27. package/types/daffodil-cart-driver-magento-2.4.7-testing.d.ts +176 -0
  28. package/types/daffodil-cart-driver-magento-2.4.7.d.ts +860 -0
  29. package/types/daffodil-cart-driver-magento-auto-testing.d.ts +1 -0
  30. package/types/daffodil-cart-driver-magento-auto.d.ts +1 -0
  31. package/types/daffodil-cart-driver-testing.d.ts +111 -118
  32. package/types/daffodil-cart-driver.d.ts +219 -262
  33. package/types/daffodil-cart-routing.d.ts +130 -149
  34. package/types/daffodil-cart-state-testing.d.ts +115 -114
  35. package/types/daffodil-cart-state.d.ts +1126 -1173
  36. package/types/daffodil-cart-testing.d.ts +146 -158
  37. package/types/daffodil-cart.d.ts +302 -321
  38. package/fesm2022/daffodil-cart-driver-magento-testing.mjs +0 -332
  39. package/fesm2022/daffodil-cart-driver-magento-testing.mjs.map +0 -1
  40. package/fesm2022/daffodil-cart-driver-magento.mjs +0 -2273
  41. package/fesm2022/daffodil-cart-driver-magento.mjs.map +0 -1
  42. package/types/daffodil-cart-driver-magento-testing.d.ts +0 -188
  43. package/types/daffodil-cart-driver-magento.d.ts +0 -999
@@ -1,358 +1,543 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable } from '@angular/core';
3
- import { faker } from '@faker-js/faker/locale/en_US';
4
- import { DaffModelFactory } from '@daffodil/core/testing';
5
- import { DaffCartTotalTypeEnum, DaffCartItemInputType } from '@daffodil/cart';
6
- import { DaffProductImageFactory } from '@daffodil/product/testing';
7
-
8
- class MockCartShippingRate {
9
- constructor() {
10
- this.id = faker.string.uuid();
11
- this.carrier = 'Birds Inc.';
12
- this.carrier_title = 'laden';
13
- this.method_code = faker.lorem.word();
14
- this.method_title = 'swallow';
15
- this.method_description = 'efficient';
16
- this.price = faker.number.int({ min: 1, max: 1500 });
17
- }
18
- }
19
- class DaffCartShippingRateFactory extends DaffModelFactory {
20
- constructor() {
21
- super(MockCartShippingRate);
22
- }
23
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartShippingRateFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
24
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartShippingRateFactory, providedIn: 'root' }); }
25
- }
26
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartShippingRateFactory, decorators: [{
27
- type: Injectable,
28
- args: [{
29
- providedIn: 'root',
30
- }]
31
- }], ctorParameters: () => [] });
32
-
33
- class MockDaffCartTotal {
34
- constructor() {
35
- this.name = faker.helpers.arrayElement([
36
- DaffCartTotalTypeEnum.grandTotal,
37
- DaffCartTotalTypeEnum.subtotalExcludingTax,
38
- DaffCartTotalTypeEnum.subtotalIncludingTax,
39
- DaffCartTotalTypeEnum.subtotalWithDiscountExcludingTax,
40
- DaffCartTotalTypeEnum.subtotalWithDiscountIncludingTax,
41
- DaffCartTotalTypeEnum.tax,
42
- DaffCartTotalTypeEnum.discount,
43
- DaffCartTotalTypeEnum.shipping,
44
- ]);
45
- this.value = faker.number.int({ min: 0, max: 999999 });
46
- this.label = faker.lorem.words();
47
- this.order = faker.number.int({ min: 0, max: 9 });
48
- }
49
- }
50
- ;
51
- class DaffCartTotalFactory extends DaffModelFactory {
52
- constructor() {
53
- super(MockDaffCartTotal);
54
- }
55
- createGrandTotal(partial = {}) {
56
- return this.create({
57
- name: DaffCartTotalTypeEnum.grandTotal,
58
- label: 'Grand Total',
59
- });
60
- }
61
- createSubtotalExcludingTax(partial = {}) {
62
- return this.create({
63
- name: DaffCartTotalTypeEnum.subtotalExcludingTax,
64
- label: 'Subtotal Excluding Tax',
65
- });
66
- }
67
- createSubtotalIncludingTax(partial = {}) {
68
- return this.create({
69
- name: DaffCartTotalTypeEnum.subtotalIncludingTax,
70
- label: 'Subtotal Including Tax',
71
- });
72
- }
73
- createSubtotalWithDiscountExcludingTax(partial = {}) {
74
- return this.create({
75
- name: DaffCartTotalTypeEnum.subtotalWithDiscountExcludingTax,
76
- label: 'Subtotal With Discount Excluding Tax',
77
- });
78
- }
79
- createSubtotalWithDiscountIncludingTax(partial = {}) {
80
- return this.create({
81
- name: DaffCartTotalTypeEnum.subtotalWithDiscountIncludingTax,
82
- label: 'Subtotal With Discount Including Tax',
83
- });
84
- }
85
- createTax(partial = {}) {
86
- return this.create({
87
- name: DaffCartTotalTypeEnum.tax,
88
- label: 'Tax',
89
- });
90
- }
91
- createDiscount(partial = {}) {
92
- return this.create({
93
- name: DaffCartTotalTypeEnum.discount,
94
- label: 'Discount',
95
- });
96
- }
97
- createShipping(partial = {}) {
98
- return this.create({
99
- name: DaffCartTotalTypeEnum.shipping,
100
- label: 'Shipping',
101
- });
102
- }
103
- createAllTotals() {
104
- return {
105
- [DaffCartTotalTypeEnum.grandTotal]: this.createGrandTotal(),
106
- [DaffCartTotalTypeEnum.subtotalExcludingTax]: this.createSubtotalExcludingTax(),
107
- [DaffCartTotalTypeEnum.subtotalIncludingTax]: this.createSubtotalIncludingTax(),
108
- [DaffCartTotalTypeEnum.subtotalWithDiscountExcludingTax]: this.createSubtotalWithDiscountExcludingTax(),
109
- [DaffCartTotalTypeEnum.subtotalWithDiscountIncludingTax]: this.createSubtotalWithDiscountIncludingTax(),
110
- [DaffCartTotalTypeEnum.tax]: this.createTax(),
111
- [DaffCartTotalTypeEnum.discount]: this.createDiscount(),
112
- [DaffCartTotalTypeEnum.shipping]: this.createShipping(),
113
- };
114
- }
115
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartTotalFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
116
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartTotalFactory, providedIn: 'root' }); }
117
- }
118
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartTotalFactory, decorators: [{
119
- type: Injectable,
120
- args: [{
121
- providedIn: 'root',
122
- }]
123
- }], ctorParameters: () => [] });
124
-
125
- class MockCart {
126
- constructor(totalFactory, shippingInformationFactory) {
127
- this.totalFactory = totalFactory;
128
- this.shippingInformationFactory = shippingInformationFactory;
129
- this.id = faker.string.uuid();
130
- this.coupons = [];
131
- this.items = [];
132
- this.billing_address = null;
133
- this.shipping_address = null;
134
- this.shipping_information = this.shippingInformationFactory.create();
135
- this.totals = this.totalFactory.createAllTotals();
136
- this.payment = null;
137
- this.available_shipping_methods = [];
138
- this.available_payment_methods = [];
139
- this.extra_attributes = {};
140
- }
141
- }
142
- ;
143
- class DaffCartFactory extends DaffModelFactory {
144
- constructor(totalFactory, shippingInformationFactory) {
145
- super(MockCart, totalFactory, shippingInformationFactory);
146
- }
147
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartFactory, deps: [{ token: DaffCartTotalFactory }, { token: DaffCartShippingRateFactory }], target: i0.ɵɵFactoryTarget.Injectable }); }
148
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartFactory, providedIn: 'root' }); }
149
- }
150
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartFactory, decorators: [{
151
- type: Injectable,
152
- args: [{
153
- providedIn: 'root',
154
- }]
155
- }], ctorParameters: () => [{ type: DaffCartTotalFactory }, { type: DaffCartShippingRateFactory }] });
156
-
157
- // TODO: rename to have Mock first
158
- /**
159
- * @role mock
160
- */
161
- class DaffMockCartItem {
162
- constructor() {
163
- this.id = faker.string.uuid();
164
- this.type = DaffCartItemInputType.Simple;
165
- this.product_id = faker.string.uuid();
166
- this.parent_item_id = faker.string.uuid();
167
- this.image = new DaffProductImageFactory().create();
168
- this.sku = 'sku';
169
- this.name = 'Product Name';
170
- this.url = `/${faker.internet.domainWord()}.html`;
171
- this.qty = faker.number.int({ min: 1, max: 100 });
172
- this.price = faker.number.int({ min: 10, max: 1500 });
173
- this.row_total = this.qty * this.price;
174
- this.in_stock = true;
175
- this._numberOfDiscounts = faker.number.int({ min: 1, max: 2 });
176
- this.discounts = this._discounts(this._numberOfDiscounts, Math.floor(this.price / this._numberOfDiscounts));
177
- }
178
- _discounts(count = 2, max = 100) {
179
- return new Array(faker.number.int(count)).fill(null).map(() => ({
180
- amount: faker.number.int({ min: 1, max }),
181
- label: faker.lorem.word(),
182
- }));
183
- }
184
- }
185
- class DaffCartItemFactory extends DaffModelFactory {
186
- constructor() {
187
- super(DaffMockCartItem);
188
- }
189
- fromProduct(product) {
190
- return this.create({
191
- product_id: product.id,
192
- name: product.name,
193
- url: product.url,
194
- image: product.images[0],
195
- sku: product.id,
196
- in_stock: product.in_stock,
197
- });
198
- }
199
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartItemFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
200
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartItemFactory, providedIn: 'root' }); }
201
- }
202
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartItemFactory, decorators: [{
203
- type: Injectable,
204
- args: [{
205
- providedIn: 'root',
206
- }]
207
- }], ctorParameters: () => [] });
208
-
209
- // TODO: rename to have Mock first
210
- /**
211
- * @role mock
212
- */
213
- class DaffMockConfigurableCartItem extends DaffMockCartItem {
214
- constructor() {
215
- super(...arguments);
216
- this.type = DaffCartItemInputType.Configurable;
217
- this.attributes = [
218
- {
219
- attribute_label: 'Color',
220
- value_label: 'Red',
221
- },
222
- {
223
- attribute_label: 'Size',
224
- value_label: 'M',
225
- },
226
- ];
227
- }
228
- }
229
- class DaffConfigurableCartItemFactory extends DaffModelFactory {
230
- constructor() {
231
- super(DaffMockConfigurableCartItem);
232
- }
233
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffConfigurableCartItemFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
234
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffConfigurableCartItemFactory, providedIn: 'root' }); }
235
- }
236
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffConfigurableCartItemFactory, decorators: [{
237
- type: Injectable,
238
- args: [{
239
- providedIn: 'root',
240
- }]
241
- }], ctorParameters: () => [] });
242
-
243
- // TODO: rename to have Mock first
244
- /**
245
- * @role mock
246
- */
247
- class DaffMockCompositeCartItem extends DaffMockCartItem {
248
- constructor() {
249
- super(...arguments);
250
- this.type = DaffCartItemInputType.Composite;
251
- this.options = [
252
- {
253
- id: faker.string.uuid(),
254
- option_label: faker.lorem.word(),
255
- value_label: faker.lorem.word(),
256
- },
257
- {
258
- id: faker.string.uuid(),
259
- option_label: faker.lorem.word(),
260
- value_label: faker.lorem.word(),
261
- },
262
- ];
263
- }
264
- }
265
- class DaffCompositeCartItemFactory extends DaffModelFactory {
266
- constructor() {
267
- super(DaffMockCompositeCartItem);
268
- }
269
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCompositeCartItemFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
270
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCompositeCartItemFactory, providedIn: 'root' }); }
271
- }
272
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCompositeCartItemFactory, decorators: [{
273
- type: Injectable,
274
- args: [{
275
- providedIn: 'root',
276
- }]
277
- }], ctorParameters: () => [] });
278
-
279
- class MockCartAddress {
280
- constructor() {
281
- this.id = faker.string.uuid();
282
- this.email = 'email@email.com';
283
- this.prefix = 'prefix';
284
- this.firstname = 'first';
285
- this.middlename = 'middle';
286
- this.lastname = 'last';
287
- this.suffix = 'suffix';
288
- this.company = 'company';
289
- this.street = 'street';
290
- this.city = 'city';
291
- this.state = 'state';
292
- this.region = 'region';
293
- this.postcode = 'postcode';
294
- this.country_id = 'ISO';
295
- this.telephone = '+1 (123)-123-1234';
296
- }
297
- }
298
- class DaffCartAddressFactory extends DaffModelFactory {
299
- constructor() {
300
- super(MockCartAddress);
301
- }
302
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartAddressFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
303
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartAddressFactory, providedIn: 'root' }); }
304
- }
305
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartAddressFactory, decorators: [{
306
- type: Injectable,
307
- args: [{
308
- providedIn: 'root',
309
- }]
310
- }], ctorParameters: () => [] });
311
-
312
- class MockCartPayment {
313
- constructor() {
314
- this.method = 'credit-card';
315
- }
316
- }
317
- class DaffCartPaymentFactory extends DaffModelFactory {
318
- constructor() {
319
- super(MockCartPayment);
320
- }
321
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartPaymentFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
322
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartPaymentFactory, providedIn: 'root' }); }
323
- }
324
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartPaymentFactory, decorators: [{
325
- type: Injectable,
326
- args: [{
327
- providedIn: 'root',
328
- }]
329
- }], ctorParameters: () => [] });
330
-
331
- class MockDaffCartCoupon {
332
- constructor() {
333
- this.id = faker.string.uuid();
334
- this.code = faker.string.alphanumeric(20);
335
- this.description = faker.lorem.words(5);
336
- }
337
- }
338
- ;
339
- class DaffCartCouponFactory extends DaffModelFactory {
340
- constructor() {
341
- super(MockDaffCartCoupon);
342
- }
343
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartCouponFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
344
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartCouponFactory, providedIn: 'root' }); }
345
- }
346
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartCouponFactory, decorators: [{
347
- type: Injectable,
348
- args: [{
349
- providedIn: 'root',
350
- }]
351
- }], ctorParameters: () => [] });
352
-
353
- /**
354
- * Generated bundle index. Do not edit.
355
- */
356
-
1
+ import * as i0 from "@angular/core";
2
+ import { Injectable } from "@angular/core";
3
+ import { faker } from "@faker-js/faker/locale/en_US";
4
+ import { DaffModelFactory } from "@daffodil/core/testing";
5
+ import { DaffCartItemInputType, DaffCartTotalTypeEnum } from "@daffodil/cart";
6
+ import { DaffProductImageFactory } from "@daffodil/product/testing";
7
+ var MockCartShippingRate = class {
8
+ constructor() {
9
+ this.id = faker.string.uuid();
10
+ this.carrier = "Birds Inc.";
11
+ this.carrier_title = "laden";
12
+ this.method_code = faker.lorem.word();
13
+ this.method_title = "swallow";
14
+ this.method_description = "efficient";
15
+ this.price = faker.number.int({
16
+ min: 1,
17
+ max: 1500
18
+ });
19
+ }
20
+ };
21
+ var DaffCartShippingRateFactory = class DaffCartShippingRateFactory extends DaffModelFactory {
22
+ constructor() {
23
+ super(MockCartShippingRate);
24
+ }
25
+ static {
26
+ this.ɵfac = i0.ɵɵngDeclareFactory({
27
+ minVersion: "12.0.0",
28
+ version: "22.2.4",
29
+ ngImport: i0,
30
+ type: DaffCartShippingRateFactory,
31
+ deps: [],
32
+ target: i0.ɵɵFactoryTarget.Injectable
33
+ });
34
+ }
35
+ static {
36
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
37
+ minVersion: "12.0.0",
38
+ version: "22.2.4",
39
+ ngImport: i0,
40
+ type: DaffCartShippingRateFactory,
41
+ providedIn: "root"
42
+ });
43
+ }
44
+ };
45
+ i0.ɵɵngDeclareClassMetadata({
46
+ minVersion: "12.0.0",
47
+ version: "22.2.4",
48
+ ngImport: i0,
49
+ type: DaffCartShippingRateFactory,
50
+ decorators: [{
51
+ type: Injectable,
52
+ args: [{ providedIn: "root" }]
53
+ }],
54
+ ctorParameters: () => []
55
+ });
56
+ var MockDaffCartTotal = class {
57
+ constructor() {
58
+ this.name = faker.helpers.arrayElement([
59
+ DaffCartTotalTypeEnum.grandTotal,
60
+ DaffCartTotalTypeEnum.subtotalExcludingTax,
61
+ DaffCartTotalTypeEnum.subtotalIncludingTax,
62
+ DaffCartTotalTypeEnum.subtotalWithDiscountExcludingTax,
63
+ DaffCartTotalTypeEnum.subtotalWithDiscountIncludingTax,
64
+ DaffCartTotalTypeEnum.tax,
65
+ DaffCartTotalTypeEnum.discount,
66
+ DaffCartTotalTypeEnum.shipping
67
+ ]);
68
+ this.value = faker.number.int({
69
+ min: 0,
70
+ max: 999999
71
+ });
72
+ this.label = faker.lorem.words();
73
+ this.order = faker.number.int({
74
+ min: 0,
75
+ max: 9
76
+ });
77
+ }
78
+ };
79
+ var DaffCartTotalFactory = class DaffCartTotalFactory extends DaffModelFactory {
80
+ constructor() {
81
+ super(MockDaffCartTotal);
82
+ }
83
+ createGrandTotal(partial = {}) {
84
+ return this.create({
85
+ name: DaffCartTotalTypeEnum.grandTotal,
86
+ label: "Grand Total"
87
+ });
88
+ }
89
+ createSubtotalExcludingTax(partial = {}) {
90
+ return this.create({
91
+ name: DaffCartTotalTypeEnum.subtotalExcludingTax,
92
+ label: "Subtotal Excluding Tax"
93
+ });
94
+ }
95
+ createSubtotalIncludingTax(partial = {}) {
96
+ return this.create({
97
+ name: DaffCartTotalTypeEnum.subtotalIncludingTax,
98
+ label: "Subtotal Including Tax"
99
+ });
100
+ }
101
+ createSubtotalWithDiscountExcludingTax(partial = {}) {
102
+ return this.create({
103
+ name: DaffCartTotalTypeEnum.subtotalWithDiscountExcludingTax,
104
+ label: "Subtotal With Discount Excluding Tax"
105
+ });
106
+ }
107
+ createSubtotalWithDiscountIncludingTax(partial = {}) {
108
+ return this.create({
109
+ name: DaffCartTotalTypeEnum.subtotalWithDiscountIncludingTax,
110
+ label: "Subtotal With Discount Including Tax"
111
+ });
112
+ }
113
+ createTax(partial = {}) {
114
+ return this.create({
115
+ name: DaffCartTotalTypeEnum.tax,
116
+ label: "Tax"
117
+ });
118
+ }
119
+ createDiscount(partial = {}) {
120
+ return this.create({
121
+ name: DaffCartTotalTypeEnum.discount,
122
+ label: "Discount"
123
+ });
124
+ }
125
+ createShipping(partial = {}) {
126
+ return this.create({
127
+ name: DaffCartTotalTypeEnum.shipping,
128
+ label: "Shipping"
129
+ });
130
+ }
131
+ createAllTotals() {
132
+ return {
133
+ [DaffCartTotalTypeEnum.grandTotal]: this.createGrandTotal(),
134
+ [DaffCartTotalTypeEnum.subtotalExcludingTax]: this.createSubtotalExcludingTax(),
135
+ [DaffCartTotalTypeEnum.subtotalIncludingTax]: this.createSubtotalIncludingTax(),
136
+ [DaffCartTotalTypeEnum.subtotalWithDiscountExcludingTax]: this.createSubtotalWithDiscountExcludingTax(),
137
+ [DaffCartTotalTypeEnum.subtotalWithDiscountIncludingTax]: this.createSubtotalWithDiscountIncludingTax(),
138
+ [DaffCartTotalTypeEnum.tax]: this.createTax(),
139
+ [DaffCartTotalTypeEnum.discount]: this.createDiscount(),
140
+ [DaffCartTotalTypeEnum.shipping]: this.createShipping()
141
+ };
142
+ }
143
+ static {
144
+ this.ɵfac = i0.ɵɵngDeclareFactory({
145
+ minVersion: "12.0.0",
146
+ version: "22.2.4",
147
+ ngImport: i0,
148
+ type: DaffCartTotalFactory,
149
+ deps: [],
150
+ target: i0.ɵɵFactoryTarget.Injectable
151
+ });
152
+ }
153
+ static {
154
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
155
+ minVersion: "12.0.0",
156
+ version: "22.2.4",
157
+ ngImport: i0,
158
+ type: DaffCartTotalFactory,
159
+ providedIn: "root"
160
+ });
161
+ }
162
+ };
163
+ i0.ɵɵngDeclareClassMetadata({
164
+ minVersion: "12.0.0",
165
+ version: "22.2.4",
166
+ ngImport: i0,
167
+ type: DaffCartTotalFactory,
168
+ decorators: [{
169
+ type: Injectable,
170
+ args: [{ providedIn: "root" }]
171
+ }],
172
+ ctorParameters: () => []
173
+ });
174
+ var MockCart = class {
175
+ constructor(totalFactory, shippingInformationFactory) {
176
+ this.totalFactory = totalFactory;
177
+ this.shippingInformationFactory = shippingInformationFactory;
178
+ this.id = faker.string.uuid();
179
+ this.coupons = [];
180
+ this.items = [];
181
+ this.billing_address = null;
182
+ this.shipping_address = null;
183
+ this.shipping_information = this.shippingInformationFactory.create();
184
+ this.totals = this.totalFactory.createAllTotals();
185
+ this.payment = null;
186
+ this.available_shipping_methods = [];
187
+ this.available_payment_methods = [];
188
+ this.extra_attributes = {};
189
+ }
190
+ };
191
+ var DaffCartFactory = class DaffCartFactory extends DaffModelFactory {
192
+ constructor(totalFactory, shippingInformationFactory) {
193
+ super(MockCart, totalFactory, shippingInformationFactory);
194
+ }
195
+ static {
196
+ this.ɵfac = i0.ɵɵngDeclareFactory({
197
+ minVersion: "12.0.0",
198
+ version: "22.2.4",
199
+ ngImport: i0,
200
+ type: DaffCartFactory,
201
+ deps: [{ token: DaffCartTotalFactory }, { token: DaffCartShippingRateFactory }],
202
+ target: i0.ɵɵFactoryTarget.Injectable
203
+ });
204
+ }
205
+ static {
206
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
207
+ minVersion: "12.0.0",
208
+ version: "22.2.4",
209
+ ngImport: i0,
210
+ type: DaffCartFactory,
211
+ providedIn: "root"
212
+ });
213
+ }
214
+ };
215
+ i0.ɵɵngDeclareClassMetadata({
216
+ minVersion: "12.0.0",
217
+ version: "22.2.4",
218
+ ngImport: i0,
219
+ type: DaffCartFactory,
220
+ decorators: [{
221
+ type: Injectable,
222
+ args: [{ providedIn: "root" }]
223
+ }],
224
+ ctorParameters: () => [{ type: DaffCartTotalFactory }, { type: DaffCartShippingRateFactory }]
225
+ });
226
+ var DaffMockCartItem = class {
227
+ constructor() {
228
+ this.id = faker.string.uuid();
229
+ this.type = DaffCartItemInputType.Simple;
230
+ this.product_id = faker.string.uuid();
231
+ this.parent_item_id = faker.string.uuid();
232
+ this.image = new DaffProductImageFactory().create();
233
+ this.sku = "sku";
234
+ this.name = "Product Name";
235
+ this.url = `/${faker.internet.domainWord()}.html`;
236
+ this.qty = faker.number.int({
237
+ min: 1,
238
+ max: 100
239
+ });
240
+ this.price = faker.number.int({
241
+ min: 10,
242
+ max: 1500
243
+ });
244
+ this.row_total = this.qty * this.price;
245
+ this.in_stock = true;
246
+ this._numberOfDiscounts = faker.number.int({
247
+ min: 1,
248
+ max: 2
249
+ });
250
+ this.discounts = this._discounts(this._numberOfDiscounts, Math.floor(this.price / this._numberOfDiscounts));
251
+ }
252
+ _discounts(count = 2, max = 100) {
253
+ return new Array(faker.number.int(count)).fill(null).map(() => ({
254
+ amount: faker.number.int({
255
+ min: 1,
256
+ max
257
+ }),
258
+ label: faker.lorem.word()
259
+ }));
260
+ }
261
+ };
262
+ var DaffCartItemFactory = class DaffCartItemFactory extends DaffModelFactory {
263
+ constructor() {
264
+ super(DaffMockCartItem);
265
+ }
266
+ fromProduct(product) {
267
+ return this.create({
268
+ product_id: product.id,
269
+ name: product.name,
270
+ url: product.url,
271
+ image: product.images[0],
272
+ sku: product.id,
273
+ in_stock: product.in_stock
274
+ });
275
+ }
276
+ static {
277
+ this.ɵfac = i0.ɵɵngDeclareFactory({
278
+ minVersion: "12.0.0",
279
+ version: "22.2.4",
280
+ ngImport: i0,
281
+ type: DaffCartItemFactory,
282
+ deps: [],
283
+ target: i0.ɵɵFactoryTarget.Injectable
284
+ });
285
+ }
286
+ static {
287
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
288
+ minVersion: "12.0.0",
289
+ version: "22.2.4",
290
+ ngImport: i0,
291
+ type: DaffCartItemFactory,
292
+ providedIn: "root"
293
+ });
294
+ }
295
+ };
296
+ i0.ɵɵngDeclareClassMetadata({
297
+ minVersion: "12.0.0",
298
+ version: "22.2.4",
299
+ ngImport: i0,
300
+ type: DaffCartItemFactory,
301
+ decorators: [{
302
+ type: Injectable,
303
+ args: [{ providedIn: "root" }]
304
+ }],
305
+ ctorParameters: () => []
306
+ });
307
+ var DaffMockConfigurableCartItem = class extends DaffMockCartItem {
308
+ constructor() {
309
+ super(...arguments);
310
+ this.type = DaffCartItemInputType.Configurable;
311
+ this.attributes = [{
312
+ attribute_label: "Color",
313
+ value_label: "Red"
314
+ }, {
315
+ attribute_label: "Size",
316
+ value_label: "M"
317
+ }];
318
+ }
319
+ };
320
+ var DaffConfigurableCartItemFactory = class DaffConfigurableCartItemFactory extends DaffModelFactory {
321
+ constructor() {
322
+ super(DaffMockConfigurableCartItem);
323
+ }
324
+ static {
325
+ this.ɵfac = i0.ɵɵngDeclareFactory({
326
+ minVersion: "12.0.0",
327
+ version: "22.2.4",
328
+ ngImport: i0,
329
+ type: DaffConfigurableCartItemFactory,
330
+ deps: [],
331
+ target: i0.ɵɵFactoryTarget.Injectable
332
+ });
333
+ }
334
+ static {
335
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
336
+ minVersion: "12.0.0",
337
+ version: "22.2.4",
338
+ ngImport: i0,
339
+ type: DaffConfigurableCartItemFactory,
340
+ providedIn: "root"
341
+ });
342
+ }
343
+ };
344
+ i0.ɵɵngDeclareClassMetadata({
345
+ minVersion: "12.0.0",
346
+ version: "22.2.4",
347
+ ngImport: i0,
348
+ type: DaffConfigurableCartItemFactory,
349
+ decorators: [{
350
+ type: Injectable,
351
+ args: [{ providedIn: "root" }]
352
+ }],
353
+ ctorParameters: () => []
354
+ });
355
+ var DaffMockCompositeCartItem = class extends DaffMockCartItem {
356
+ constructor() {
357
+ super(...arguments);
358
+ this.type = DaffCartItemInputType.Composite;
359
+ this.options = [{
360
+ id: faker.string.uuid(),
361
+ option_label: faker.lorem.word(),
362
+ value_label: faker.lorem.word()
363
+ }, {
364
+ id: faker.string.uuid(),
365
+ option_label: faker.lorem.word(),
366
+ value_label: faker.lorem.word()
367
+ }];
368
+ }
369
+ };
370
+ var DaffCompositeCartItemFactory = class DaffCompositeCartItemFactory extends DaffModelFactory {
371
+ constructor() {
372
+ super(DaffMockCompositeCartItem);
373
+ }
374
+ static {
375
+ this.ɵfac = i0.ɵɵngDeclareFactory({
376
+ minVersion: "12.0.0",
377
+ version: "22.2.4",
378
+ ngImport: i0,
379
+ type: DaffCompositeCartItemFactory,
380
+ deps: [],
381
+ target: i0.ɵɵFactoryTarget.Injectable
382
+ });
383
+ }
384
+ static {
385
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
386
+ minVersion: "12.0.0",
387
+ version: "22.2.4",
388
+ ngImport: i0,
389
+ type: DaffCompositeCartItemFactory,
390
+ providedIn: "root"
391
+ });
392
+ }
393
+ };
394
+ i0.ɵɵngDeclareClassMetadata({
395
+ minVersion: "12.0.0",
396
+ version: "22.2.4",
397
+ ngImport: i0,
398
+ type: DaffCompositeCartItemFactory,
399
+ decorators: [{
400
+ type: Injectable,
401
+ args: [{ providedIn: "root" }]
402
+ }],
403
+ ctorParameters: () => []
404
+ });
405
+ var MockCartAddress = class {
406
+ constructor() {
407
+ this.id = faker.string.uuid();
408
+ this.email = "email@email.com";
409
+ this.prefix = "prefix";
410
+ this.firstname = "first";
411
+ this.middlename = "middle";
412
+ this.lastname = "last";
413
+ this.suffix = "suffix";
414
+ this.company = "company";
415
+ this.street = "street";
416
+ this.city = "city";
417
+ this.state = "state";
418
+ this.region = "region";
419
+ this.postcode = "postcode";
420
+ this.country_id = "ISO";
421
+ this.telephone = "+1 (123)-123-1234";
422
+ }
423
+ };
424
+ var DaffCartAddressFactory = class DaffCartAddressFactory extends DaffModelFactory {
425
+ constructor() {
426
+ super(MockCartAddress);
427
+ }
428
+ static {
429
+ this.ɵfac = i0.ɵɵngDeclareFactory({
430
+ minVersion: "12.0.0",
431
+ version: "22.2.4",
432
+ ngImport: i0,
433
+ type: DaffCartAddressFactory,
434
+ deps: [],
435
+ target: i0.ɵɵFactoryTarget.Injectable
436
+ });
437
+ }
438
+ static {
439
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
440
+ minVersion: "12.0.0",
441
+ version: "22.2.4",
442
+ ngImport: i0,
443
+ type: DaffCartAddressFactory,
444
+ providedIn: "root"
445
+ });
446
+ }
447
+ };
448
+ i0.ɵɵngDeclareClassMetadata({
449
+ minVersion: "12.0.0",
450
+ version: "22.2.4",
451
+ ngImport: i0,
452
+ type: DaffCartAddressFactory,
453
+ decorators: [{
454
+ type: Injectable,
455
+ args: [{ providedIn: "root" }]
456
+ }],
457
+ ctorParameters: () => []
458
+ });
459
+ var MockCartPayment = class {
460
+ constructor() {
461
+ this.method = "credit-card";
462
+ }
463
+ };
464
+ var DaffCartPaymentFactory = class DaffCartPaymentFactory extends DaffModelFactory {
465
+ constructor() {
466
+ super(MockCartPayment);
467
+ }
468
+ static {
469
+ this.ɵfac = i0.ɵɵngDeclareFactory({
470
+ minVersion: "12.0.0",
471
+ version: "22.2.4",
472
+ ngImport: i0,
473
+ type: DaffCartPaymentFactory,
474
+ deps: [],
475
+ target: i0.ɵɵFactoryTarget.Injectable
476
+ });
477
+ }
478
+ static {
479
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
480
+ minVersion: "12.0.0",
481
+ version: "22.2.4",
482
+ ngImport: i0,
483
+ type: DaffCartPaymentFactory,
484
+ providedIn: "root"
485
+ });
486
+ }
487
+ };
488
+ i0.ɵɵngDeclareClassMetadata({
489
+ minVersion: "12.0.0",
490
+ version: "22.2.4",
491
+ ngImport: i0,
492
+ type: DaffCartPaymentFactory,
493
+ decorators: [{
494
+ type: Injectable,
495
+ args: [{ providedIn: "root" }]
496
+ }],
497
+ ctorParameters: () => []
498
+ });
499
+ var MockDaffCartCoupon = class {
500
+ constructor() {
501
+ this.id = faker.string.uuid();
502
+ this.code = faker.string.alphanumeric(20);
503
+ this.description = faker.lorem.words(5);
504
+ }
505
+ };
506
+ var DaffCartCouponFactory = class DaffCartCouponFactory extends DaffModelFactory {
507
+ constructor() {
508
+ super(MockDaffCartCoupon);
509
+ }
510
+ static {
511
+ this.ɵfac = i0.ɵɵngDeclareFactory({
512
+ minVersion: "12.0.0",
513
+ version: "22.2.4",
514
+ ngImport: i0,
515
+ type: DaffCartCouponFactory,
516
+ deps: [],
517
+ target: i0.ɵɵFactoryTarget.Injectable
518
+ });
519
+ }
520
+ static {
521
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
522
+ minVersion: "12.0.0",
523
+ version: "22.2.4",
524
+ ngImport: i0,
525
+ type: DaffCartCouponFactory,
526
+ providedIn: "root"
527
+ });
528
+ }
529
+ };
530
+ i0.ɵɵngDeclareClassMetadata({
531
+ minVersion: "12.0.0",
532
+ version: "22.2.4",
533
+ ngImport: i0,
534
+ type: DaffCartCouponFactory,
535
+ decorators: [{
536
+ type: Injectable,
537
+ args: [{ providedIn: "root" }]
538
+ }],
539
+ ctorParameters: () => []
540
+ });
357
541
  export { DaffCartAddressFactory, DaffCartCouponFactory, DaffCartFactory, DaffCartItemFactory, DaffCartPaymentFactory, DaffCartShippingRateFactory, DaffCartTotalFactory, DaffCompositeCartItemFactory, DaffConfigurableCartItemFactory, DaffMockCartItem, DaffMockCompositeCartItem, DaffMockConfigurableCartItem, MockCart, MockCartAddress, MockCartPayment, MockCartShippingRate, MockDaffCartCoupon, MockDaffCartTotal };
358
- //# sourceMappingURL=daffodil-cart-testing.mjs.map
542
+
543
+ //# sourceMappingURL=daffodil-cart-testing.mjs.map