@reactionary/fake 0.10.3 → 0.10.4
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.
|
@@ -63,11 +63,21 @@ class FakeCartCapability extends CartCapability {
|
|
|
63
63
|
}
|
|
64
64
|
async add(payload) {
|
|
65
65
|
const cartId = payload?.cart?.key || `cart-${this.generator.string.uuid()}`;
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
const currency = this.context.languageContext.currencyCode;
|
|
67
|
+
const zero = { value: 0, currency };
|
|
68
|
+
const cart = this.carts.get(cartId) || this.factory.parseCart(this.context, {
|
|
69
|
+
identifier: { key: cartId },
|
|
70
|
+
user: { userId: "anonymous" },
|
|
71
|
+
price: {
|
|
72
|
+
totalTax: zero,
|
|
73
|
+
totalDiscount: zero,
|
|
74
|
+
totalSurcharge: zero,
|
|
75
|
+
totalShipping: zero,
|
|
76
|
+
totalProductPrice: zero,
|
|
77
|
+
grandTotal: zero
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
this.carts.set(cartId, cart);
|
|
71
81
|
const existingItemIndex = cart.items.findIndex(
|
|
72
82
|
(item) => item.variant.sku === payload.variant.sku
|
|
73
83
|
);
|
|
@@ -114,12 +114,15 @@ class FakeCategoryCapability extends CategoryCapability {
|
|
|
114
114
|
}
|
|
115
115
|
async findChildCategories(payload) {
|
|
116
116
|
const items = this.childCategories.get(payload.parentId.key) || [];
|
|
117
|
+
const { pageNumber, pageSize } = payload.paginationOptions;
|
|
118
|
+
const start = (pageNumber - 1) * pageSize;
|
|
119
|
+
const pagedItems = items.slice(start, start + pageSize);
|
|
117
120
|
const result = {
|
|
118
|
-
items,
|
|
119
|
-
pageSize
|
|
120
|
-
pageNumber
|
|
121
|
+
items: pagedItems,
|
|
122
|
+
pageSize,
|
|
123
|
+
pageNumber,
|
|
121
124
|
totalCount: items.length,
|
|
122
|
-
totalPages:
|
|
125
|
+
totalPages: Math.ceil(items.length / pageSize)
|
|
123
126
|
};
|
|
124
127
|
return success(this.factory.parseCategoryPaginatedResult(this.context, result, payload));
|
|
125
128
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactionary/fake",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "git+https://github.com/Solteq/reactionary.git"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@reactionary/core": "0.10.
|
|
12
|
+
"@reactionary/core": "0.10.4",
|
|
13
13
|
"zod": "4.1.9",
|
|
14
14
|
"@faker-js/faker": "^9.8.0"
|
|
15
15
|
},
|