@shopgate/pwa-common-commerce 7.32.0-beta.1 → 7.32.0-beta.10
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/cart/helpers/tax.js +2 -2
- package/cart/subscriptions/index.js +3 -3
- package/package.json +4 -4
- package/product/index.js +0 -1
- package/cart/selectors/spec.js +0 -189
- package/favorites/streams/spec.js +0 -517
- package/favorites/subscriptions/spec.js +0 -702
- package/product/collections/ProductImageFormats.js +0 -63
- package/product/collections/index.js +0 -1
- package/reviews/action-creators/spec.js +0 -40
- package/reviews/actions/spec.js +0 -255
- package/reviews/reducers/spec.js +0 -214
- package/reviews/selectors/spec.js +0 -100
- package/reviews/streams/spec.js +0 -26
- package/search/helpers/spec.js +0 -19
package/cart/helpers/tax.js
CHANGED
|
@@ -153,10 +153,10 @@ export default function cart(subscribe) {
|
|
|
153
153
|
message,
|
|
154
154
|
handled,
|
|
155
155
|
code,
|
|
156
|
-
|
|
157
|
-
translated,
|
|
158
|
-
context
|
|
156
|
+
translated
|
|
159
157
|
} = errors[0];
|
|
158
|
+
const context = errors[0].context || errors[0].pipeline;
|
|
159
|
+
const additionalParams = errors[0].additionalParams || errors[0].messageParams || {};
|
|
160
160
|
|
|
161
161
|
// Some errors are already handled automatically before
|
|
162
162
|
if (handled) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/pwa-common-commerce",
|
|
3
|
-
"version": "7.32.0-beta.
|
|
3
|
+
"version": "7.32.0-beta.10",
|
|
4
4
|
"description": "Commerce library for the Shopgate Connect PWA.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Shopgate <support@shopgate.com>",
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
"connect"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"immer": "^11.1.
|
|
18
|
+
"immer": "^11.1.11",
|
|
19
19
|
"react-cookie": "^4.0.3",
|
|
20
20
|
"reselect": "^4.1.8"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@shopgate/pwa-common": "7.32.0-beta.
|
|
24
|
-
"@shopgate/pwa-core": "7.32.0-beta.
|
|
23
|
+
"@shopgate/pwa-common": "7.32.0-beta.10",
|
|
24
|
+
"@shopgate/pwa-core": "7.32.0-beta.10",
|
|
25
25
|
"@types/lodash": "^4.17.24",
|
|
26
26
|
"lodash": "^4.17.23",
|
|
27
27
|
"react": "^17.0.2",
|
package/product/index.js
CHANGED
|
@@ -15,7 +15,6 @@ export { default as fetchProductShipping } from "./actions/fetchProductShipping"
|
|
|
15
15
|
export { default as fetchProductVariants } from "./actions/fetchProductVariants";
|
|
16
16
|
|
|
17
17
|
// COLLECTIONS
|
|
18
|
-
export { default as productImageFormats } from "./collections/ProductImageFormats";
|
|
19
18
|
|
|
20
19
|
// CONSTANTS
|
|
21
20
|
export * from "./constants/index";
|
package/cart/selectors/spec.js
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
/* eslint-disable extra-rules/no-single-line-objects */
|
|
2
|
-
import { mockedState as mockedProductState, mockedProductMetadata, mockedVariantProductMetadata, mockedVariantMetadata } from "../../product/selectors/product.mock";
|
|
3
|
-
import { getFlags, getAddToCartMetadata, hasCouponSupport, getIsFetching, getSubTotal, getDiscounts, getDiscountsAmount, getTax, getGrandTotal } from "./index";
|
|
4
|
-
import { CART_TOTALS_TYPE_DISCOUNT, CART_TOTALS_TYPE_GRAND, CART_TOTALS_TYPE_SUB, CART_TOTALS_TYPE_TAX } from "../constants";
|
|
5
|
-
describe('Cart selectors', () => {
|
|
6
|
-
describe('getFlags()', () => {
|
|
7
|
-
it('should return an empty object if no flags are available', () => {
|
|
8
|
-
const result = getFlags({
|
|
9
|
-
cart: {
|
|
10
|
-
data: {}
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
expect(result).toEqual({});
|
|
14
|
-
});
|
|
15
|
-
it('should return the flags if available', () => {
|
|
16
|
-
const flags = {
|
|
17
|
-
coupons: true,
|
|
18
|
-
orderable: true
|
|
19
|
-
};
|
|
20
|
-
const result = getFlags({
|
|
21
|
-
cart: {
|
|
22
|
-
data: {
|
|
23
|
-
flags
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
expect(result).toEqual(flags);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
describe('getAddToCartMetadata()', () => {
|
|
31
|
-
let mockedState;
|
|
32
|
-
beforeEach(() => {
|
|
33
|
-
// Create a deep copy of the state to avoid unintended selector caching.
|
|
34
|
-
mockedState = JSON.parse(JSON.stringify(mockedProductState));
|
|
35
|
-
});
|
|
36
|
-
it('should return the metadata of the variant product', () => {
|
|
37
|
-
const productId = 'product_1';
|
|
38
|
-
const variantId = 'product_2';
|
|
39
|
-
const result = getAddToCartMetadata(mockedState, {
|
|
40
|
-
productId,
|
|
41
|
-
variantId
|
|
42
|
-
});
|
|
43
|
-
expect(result).toEqual(mockedVariantProductMetadata);
|
|
44
|
-
});
|
|
45
|
-
it('should return the metadata of the base product', () => {
|
|
46
|
-
const productId = 'product_1';
|
|
47
|
-
const variantId = 'product_2';
|
|
48
|
-
delete mockedState.product.productsById[variantId].productData.metadata;
|
|
49
|
-
const result = getAddToCartMetadata(mockedState, {
|
|
50
|
-
productId,
|
|
51
|
-
variantId
|
|
52
|
-
});
|
|
53
|
-
expect(result).toEqual(mockedProductMetadata);
|
|
54
|
-
});
|
|
55
|
-
it('should return the metadata of the variant data assigned to the variant product', () => {
|
|
56
|
-
const productId = 'product_1';
|
|
57
|
-
const variantId = 'product_3';
|
|
58
|
-
const result = getAddToCartMetadata(mockedState, {
|
|
59
|
-
productId,
|
|
60
|
-
variantId
|
|
61
|
-
});
|
|
62
|
-
expect(result).toEqual(mockedVariantMetadata);
|
|
63
|
-
});
|
|
64
|
-
it('should return null when no metadata can be determined', () => {
|
|
65
|
-
const productId = 'product_10';
|
|
66
|
-
const variantId = 'product_11';
|
|
67
|
-
const result = getAddToCartMetadata(mockedState, {
|
|
68
|
-
productId,
|
|
69
|
-
variantId
|
|
70
|
-
});
|
|
71
|
-
expect(result).toBeNull();
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
describe('hasCouponSupport()', () => {
|
|
75
|
-
it('should return true if no flags are available', () => {
|
|
76
|
-
const result = hasCouponSupport({
|
|
77
|
-
cart: {
|
|
78
|
-
data: {}
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
expect(result).toEqual(true);
|
|
82
|
-
});
|
|
83
|
-
it('should return true if the coupons flag is not available', () => {
|
|
84
|
-
const result = hasCouponSupport({
|
|
85
|
-
cart: {
|
|
86
|
-
data: {
|
|
87
|
-
flags: {}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
expect(result).toEqual(true);
|
|
92
|
-
});
|
|
93
|
-
it('should return true if the flag is true', () => {
|
|
94
|
-
const result = hasCouponSupport({
|
|
95
|
-
cart: {
|
|
96
|
-
data: {
|
|
97
|
-
flags: {
|
|
98
|
-
coupons: true
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
expect(result).toEqual(true);
|
|
104
|
-
});
|
|
105
|
-
it('should return false if the flag is false', () => {
|
|
106
|
-
const result = hasCouponSupport({
|
|
107
|
-
cart: {
|
|
108
|
-
data: {
|
|
109
|
-
flags: {
|
|
110
|
-
coupons: false
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
expect(result).toEqual(false);
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
describe('isFetching()', () => {
|
|
119
|
-
it('should return true if cart is fetching', () => {
|
|
120
|
-
const result = getIsFetching({
|
|
121
|
-
cart: {
|
|
122
|
-
data: {
|
|
123
|
-
isFetching: true
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
expect(result).toEqual(true);
|
|
128
|
-
});
|
|
129
|
-
it('should return false when no store information is given', () => {
|
|
130
|
-
const result = getIsFetching({
|
|
131
|
-
cart: {
|
|
132
|
-
data: {}
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
expect(result).toEqual(false);
|
|
136
|
-
});
|
|
137
|
-
it('should return false if cart is not fetching', () => {
|
|
138
|
-
const result = getIsFetching({
|
|
139
|
-
cart: {
|
|
140
|
-
data: {
|
|
141
|
-
isFetching: false
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
expect(result).toEqual(false);
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
describe('getTotals', () => {
|
|
149
|
-
const mockedState = {
|
|
150
|
-
cart: {
|
|
151
|
-
data: {
|
|
152
|
-
totals: [{
|
|
153
|
-
type: CART_TOTALS_TYPE_SUB,
|
|
154
|
-
amount: 100
|
|
155
|
-
}, {
|
|
156
|
-
type: CART_TOTALS_TYPE_DISCOUNT,
|
|
157
|
-
amount: 5
|
|
158
|
-
}, {
|
|
159
|
-
type: CART_TOTALS_TYPE_DISCOUNT,
|
|
160
|
-
amount: 2
|
|
161
|
-
}, {
|
|
162
|
-
type: CART_TOTALS_TYPE_TAX,
|
|
163
|
-
label: 'inkl. 26% MwSt.',
|
|
164
|
-
amount: 5
|
|
165
|
-
}, {
|
|
166
|
-
type: CART_TOTALS_TYPE_GRAND,
|
|
167
|
-
amount: 105
|
|
168
|
-
}]
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
it('should return subtotal', () => {
|
|
173
|
-
expect(getSubTotal(mockedState)).toEqual(100);
|
|
174
|
-
});
|
|
175
|
-
it('should return discount', () => {
|
|
176
|
-
expect(getDiscounts(mockedState)).toEqual([mockedState.cart.data.totals[1], mockedState.cart.data.totals[2]]);
|
|
177
|
-
});
|
|
178
|
-
it('should return discount amount', () => {
|
|
179
|
-
expect(getDiscountsAmount(mockedState)).toEqual(7);
|
|
180
|
-
});
|
|
181
|
-
it('should return tax', () => {
|
|
182
|
-
expect(getTax(mockedState)).toEqual(mockedState.cart.data.totals[3]);
|
|
183
|
-
});
|
|
184
|
-
it('should return grand total', () => {
|
|
185
|
-
expect(getGrandTotal(mockedState)).toEqual(105);
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
/* eslint-enable extra-rules/no-single-line-objects */
|