@commercetools-frontend/experimental-components 6.2.1 → 6.2.2

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.
@@ -0,0 +1,219 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var msw = require('msw');
6
+ var _lastIndexOfInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/last-index-of');
7
+ var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
8
+ var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
9
+ var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
10
+ var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
11
+ var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
12
+ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
13
+ var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
14
+ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
15
+ var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
16
+ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
17
+
18
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
19
+
20
+ var _lastIndexOfInstanceProperty__default = /*#__PURE__*/_interopDefault(_lastIndexOfInstanceProperty);
21
+ var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
22
+ var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
23
+ var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
24
+ var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
25
+ var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
26
+ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
27
+ var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
28
+ var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
29
+ var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
30
+
31
+ const handlers$8 = {
32
+ TotalNumberOfStores: {
33
+ all: total => msw.graphql.query('TotalNumberOfStores', (req, res, ctx) => {
34
+ return res(ctx.data({
35
+ totalNumberOfStores: {
36
+ total
37
+ }
38
+ }));
39
+ })
40
+ }
41
+ };
42
+
43
+ const handlers$7 = {
44
+ TypeDefinitions: {
45
+ all: typeDefinitions => msw.graphql.query('FetchTypeDefinitionsQuery', (req, res, ctx) => res(ctx.data({
46
+ typeDefinitions
47
+ })))
48
+ }
49
+ };
50
+
51
+ const graphqlQueries = {
52
+ ASSOCIATE_ROLE: 'associateRoles',
53
+ ATTRIBUTE_GROUP: 'attributeGroups',
54
+ BUSINESS_UNIT: 'businessUnits',
55
+ CART: 'carts',
56
+ CART_DISCOUNT: 'cartDiscounts',
57
+ CATEGORY: 'categories',
58
+ CHANNEL: 'channels',
59
+ CUSTOMER: 'customers',
60
+ CUSTOMER_GROUP: 'customerGroups',
61
+ DISCOUNT_CODE: 'discountCodes',
62
+ INVENTORY_ENTRY: 'inventoryEntries',
63
+ ORDER: 'orders',
64
+ PAYMENT: 'payments',
65
+ PRODUCT: 'products',
66
+ PRODUCT_DISCOUNT: 'productDiscounts',
67
+ PRODUCT_SELECTION: 'productSelections',
68
+ PRODUCT_TYPE: 'productTypes',
69
+ SHIPPING_METHOD: 'shippingMethods',
70
+ STORE: 'stores',
71
+ TAX_CATEGORY: 'taxCategories',
72
+ ZONE: 'zones'
73
+ };
74
+ const handlers$6 = {
75
+ DuplicatedField: {
76
+ total: (total, resourceType) => msw.graphql.query('FetchResourceTypeDuplicatedField', (req, res, ctx) => {
77
+ if (!graphqlQueries[resourceType]) return res(ctx.data({}));
78
+ return res(ctx.data({
79
+ [graphqlQueries[resourceType]]: {
80
+ total
81
+ }
82
+ }));
83
+ })
84
+ }
85
+ };
86
+
87
+ const handlers$5 = {
88
+ ProductSelections: {
89
+ all: productSelections => msw.graphql.query('FetchProductSelections', (req, res, ctx) => res(ctx.data({
90
+ productSelections
91
+ })))
92
+ }
93
+ };
94
+
95
+ const handlers$4 = {
96
+ ProductSelections: {
97
+ total: total => msw.graphql.query('FetchProductSelectionsTotal', (req, res, ctx) => res(ctx.data({
98
+ productSelections: {
99
+ total,
100
+ __typename: 'ProductSelectionQueryResult'
101
+ }
102
+ })))
103
+ }
104
+ };
105
+
106
+ const extractKeysFromWherePredicateClause = function () {
107
+ let whereClause = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
108
+ return whereClause.substring(_lastIndexOfInstanceProperty__default["default"](whereClause).call(whereClause, '("') + 1, _lastIndexOfInstanceProperty__default["default"](whereClause).call(whereClause, '")')).replace(/["]/g, '').split(', ');
109
+ };
110
+ const handlers$3 = {
111
+ StoresList: {
112
+ all: stores => msw.graphql.query('FetchStoresQuery', (req, res, ctx) => {
113
+ // GIVEN req.variables.where is specified
114
+ // THEN return only stores that are being requested (filtering stores based on IDs)
115
+ // ELSE return all the stores (without filtering any)
116
+ if (req.variables.where) {
117
+ var _context;
118
+ const requestedStoreKeys = extractKeysFromWherePredicateClause(req.variables.where);
119
+ const filteredStoreResults = _filterInstanceProperty__default["default"](_context = stores.results).call(_context, store => _includesInstanceProperty__default["default"](requestedStoreKeys).call(requestedStoreKeys, store.key));
120
+ return res(ctx.data({
121
+ stores: {
122
+ offset: 0,
123
+ total: filteredStoreResults.length,
124
+ count: filteredStoreResults.length,
125
+ results: filteredStoreResults,
126
+ __typename: 'StoresQueryResult'
127
+ }
128
+ }));
129
+ }
130
+ return res(ctx.data({
131
+ stores
132
+ }));
133
+ }),
134
+ withProductSelections: stores => msw.graphql.query('FetchStoresQuery', (req, res, ctx) => {
135
+ // GIVEN req.variables.where is specified
136
+ // THEN return only stores that are being requested (filtering stores based on IDs)
137
+ // ELSE return all the stores (without filtering any)
138
+ if (req.variables.where) {
139
+ var _context2;
140
+ const requestedStoreKeys = extractKeysFromWherePredicateClause(req.variables.where);
141
+ const filteredStoreResults = _filterInstanceProperty__default["default"](_context2 = stores.results).call(_context2, store => _includesInstanceProperty__default["default"](requestedStoreKeys).call(requestedStoreKeys, store.key));
142
+ return res(ctx.data({
143
+ stores: {
144
+ offset: 0,
145
+ total: filteredStoreResults.length,
146
+ count: filteredStoreResults.length,
147
+ results: filteredStoreResults,
148
+ __typename: 'StoresQueryResult'
149
+ }
150
+ }));
151
+ }
152
+ return res(ctx.data({
153
+ stores
154
+ }));
155
+ })
156
+ }
157
+ };
158
+
159
+ const handlers$2 = {
160
+ FetchStoresByField: {
161
+ all: stores => msw.graphql.query('FetchStoresByField', (req, res, ctx) => {
162
+ return res(ctx.data({
163
+ storesByField: stores
164
+ }));
165
+ })
166
+ }
167
+ };
168
+
169
+ const handlers$1 = {
170
+ FetchStoresByWherePredicate: {
171
+ all: stores => msw.graphql.query('FetchStoresByWherePredicate', (req, res, ctx) => {
172
+ return res(ctx.data({
173
+ storesByWherePredicate: {
174
+ results: stores,
175
+ total: stores.length
176
+ }
177
+ }));
178
+ })
179
+ }
180
+ };
181
+
182
+ const handlers = {
183
+ PlatformLimits: {
184
+ all: platformLimiits => msw.graphql.query('PlatformLimitsFetcherQuery', (req, res, ctx) => res(ctx.data({
185
+ limits: platformLimiits
186
+ })))
187
+ }
188
+ };
189
+
190
+ function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
191
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
192
+ var FetchRoleBasedChannels = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchRoleBasedChannels" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "limit" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "Int" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "where" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "channels" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "where" }, value: { kind: "Variable", name: { kind: "Name", value: "where" } } }, { kind: "Argument", name: { kind: "Name", value: "limit" }, value: { kind: "Variable", name: { kind: "Name", value: "limit" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "results" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }] } }] } }], loc: { start: 0, end: 210, source: { body: "query FetchRoleBasedChannels($limit: Int!, $where: String!) {\n channels(where: $where, limit: $limit) {\n results {\n id\n key\n nameAllLocales {\n locale\n value\n }\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
193
+ const createFetchStoreDistributionChannelsQueryMock = custom => _objectSpread({
194
+ request: {
195
+ variables: {
196
+ where: `roles contains any ("ProductDistribution")`,
197
+ limit: 500
198
+ },
199
+ query: FetchRoleBasedChannels
200
+ },
201
+ result: {
202
+ data: {
203
+ channels: {
204
+ results: []
205
+ }
206
+ }
207
+ }
208
+ }, custom);
209
+
210
+ exports.createFetchStoreDistributionChannelsQueryMock = createFetchStoreDistributionChannelsQueryMock;
211
+ exports.customFieldDefinitionsMockHanders = handlers$7;
212
+ exports.isFieldDuplicatedMockHandlers = handlers$6;
213
+ exports.platformLimitsMockHandlers = handlers;
214
+ exports.productSelectionsFetcherMockHandler = handlers$5;
215
+ exports.productSelectionsTotalFetcherMockHandler = handlers$4;
216
+ exports.storesListConnectorMockHandlers = handlers$3;
217
+ exports.useStoreByFieldFetcherHandlers = handlers$2;
218
+ exports.useStoresByWherePredicateFetcherHandlers = handlers$1;
219
+ exports.useTotalNumberOfStoresFetcherHandlers = handlers$8;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./commercetools-frontend-experimental-components-test-utils.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./commercetools-frontend-experimental-components-test-utils.cjs.dev.js");
7
+ }
@@ -0,0 +1,219 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var msw = require('msw');
6
+ var _lastIndexOfInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/last-index-of');
7
+ var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
8
+ var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
9
+ var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
10
+ var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
11
+ var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
12
+ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
13
+ var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
14
+ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
15
+ var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
16
+ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
17
+
18
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
19
+
20
+ var _lastIndexOfInstanceProperty__default = /*#__PURE__*/_interopDefault(_lastIndexOfInstanceProperty);
21
+ var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
22
+ var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
23
+ var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
24
+ var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
25
+ var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
26
+ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
27
+ var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
28
+ var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
29
+ var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
30
+
31
+ const handlers$8 = {
32
+ TotalNumberOfStores: {
33
+ all: total => msw.graphql.query('TotalNumberOfStores', (req, res, ctx) => {
34
+ return res(ctx.data({
35
+ totalNumberOfStores: {
36
+ total
37
+ }
38
+ }));
39
+ })
40
+ }
41
+ };
42
+
43
+ const handlers$7 = {
44
+ TypeDefinitions: {
45
+ all: typeDefinitions => msw.graphql.query('FetchTypeDefinitionsQuery', (req, res, ctx) => res(ctx.data({
46
+ typeDefinitions
47
+ })))
48
+ }
49
+ };
50
+
51
+ const graphqlQueries = {
52
+ ASSOCIATE_ROLE: 'associateRoles',
53
+ ATTRIBUTE_GROUP: 'attributeGroups',
54
+ BUSINESS_UNIT: 'businessUnits',
55
+ CART: 'carts',
56
+ CART_DISCOUNT: 'cartDiscounts',
57
+ CATEGORY: 'categories',
58
+ CHANNEL: 'channels',
59
+ CUSTOMER: 'customers',
60
+ CUSTOMER_GROUP: 'customerGroups',
61
+ DISCOUNT_CODE: 'discountCodes',
62
+ INVENTORY_ENTRY: 'inventoryEntries',
63
+ ORDER: 'orders',
64
+ PAYMENT: 'payments',
65
+ PRODUCT: 'products',
66
+ PRODUCT_DISCOUNT: 'productDiscounts',
67
+ PRODUCT_SELECTION: 'productSelections',
68
+ PRODUCT_TYPE: 'productTypes',
69
+ SHIPPING_METHOD: 'shippingMethods',
70
+ STORE: 'stores',
71
+ TAX_CATEGORY: 'taxCategories',
72
+ ZONE: 'zones'
73
+ };
74
+ const handlers$6 = {
75
+ DuplicatedField: {
76
+ total: (total, resourceType) => msw.graphql.query('FetchResourceTypeDuplicatedField', (req, res, ctx) => {
77
+ if (!graphqlQueries[resourceType]) return res(ctx.data({}));
78
+ return res(ctx.data({
79
+ [graphqlQueries[resourceType]]: {
80
+ total
81
+ }
82
+ }));
83
+ })
84
+ }
85
+ };
86
+
87
+ const handlers$5 = {
88
+ ProductSelections: {
89
+ all: productSelections => msw.graphql.query('FetchProductSelections', (req, res, ctx) => res(ctx.data({
90
+ productSelections
91
+ })))
92
+ }
93
+ };
94
+
95
+ const handlers$4 = {
96
+ ProductSelections: {
97
+ total: total => msw.graphql.query('FetchProductSelectionsTotal', (req, res, ctx) => res(ctx.data({
98
+ productSelections: {
99
+ total,
100
+ __typename: 'ProductSelectionQueryResult'
101
+ }
102
+ })))
103
+ }
104
+ };
105
+
106
+ const extractKeysFromWherePredicateClause = function () {
107
+ let whereClause = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
108
+ return whereClause.substring(_lastIndexOfInstanceProperty__default["default"](whereClause).call(whereClause, '("') + 1, _lastIndexOfInstanceProperty__default["default"](whereClause).call(whereClause, '")')).replace(/["]/g, '').split(', ');
109
+ };
110
+ const handlers$3 = {
111
+ StoresList: {
112
+ all: stores => msw.graphql.query('FetchStoresQuery', (req, res, ctx) => {
113
+ // GIVEN req.variables.where is specified
114
+ // THEN return only stores that are being requested (filtering stores based on IDs)
115
+ // ELSE return all the stores (without filtering any)
116
+ if (req.variables.where) {
117
+ var _context;
118
+ const requestedStoreKeys = extractKeysFromWherePredicateClause(req.variables.where);
119
+ const filteredStoreResults = _filterInstanceProperty__default["default"](_context = stores.results).call(_context, store => _includesInstanceProperty__default["default"](requestedStoreKeys).call(requestedStoreKeys, store.key));
120
+ return res(ctx.data({
121
+ stores: {
122
+ offset: 0,
123
+ total: filteredStoreResults.length,
124
+ count: filteredStoreResults.length,
125
+ results: filteredStoreResults,
126
+ __typename: 'StoresQueryResult'
127
+ }
128
+ }));
129
+ }
130
+ return res(ctx.data({
131
+ stores
132
+ }));
133
+ }),
134
+ withProductSelections: stores => msw.graphql.query('FetchStoresQuery', (req, res, ctx) => {
135
+ // GIVEN req.variables.where is specified
136
+ // THEN return only stores that are being requested (filtering stores based on IDs)
137
+ // ELSE return all the stores (without filtering any)
138
+ if (req.variables.where) {
139
+ var _context2;
140
+ const requestedStoreKeys = extractKeysFromWherePredicateClause(req.variables.where);
141
+ const filteredStoreResults = _filterInstanceProperty__default["default"](_context2 = stores.results).call(_context2, store => _includesInstanceProperty__default["default"](requestedStoreKeys).call(requestedStoreKeys, store.key));
142
+ return res(ctx.data({
143
+ stores: {
144
+ offset: 0,
145
+ total: filteredStoreResults.length,
146
+ count: filteredStoreResults.length,
147
+ results: filteredStoreResults,
148
+ __typename: 'StoresQueryResult'
149
+ }
150
+ }));
151
+ }
152
+ return res(ctx.data({
153
+ stores
154
+ }));
155
+ })
156
+ }
157
+ };
158
+
159
+ const handlers$2 = {
160
+ FetchStoresByField: {
161
+ all: stores => msw.graphql.query('FetchStoresByField', (req, res, ctx) => {
162
+ return res(ctx.data({
163
+ storesByField: stores
164
+ }));
165
+ })
166
+ }
167
+ };
168
+
169
+ const handlers$1 = {
170
+ FetchStoresByWherePredicate: {
171
+ all: stores => msw.graphql.query('FetchStoresByWherePredicate', (req, res, ctx) => {
172
+ return res(ctx.data({
173
+ storesByWherePredicate: {
174
+ results: stores,
175
+ total: stores.length
176
+ }
177
+ }));
178
+ })
179
+ }
180
+ };
181
+
182
+ const handlers = {
183
+ PlatformLimits: {
184
+ all: platformLimiits => msw.graphql.query('PlatformLimitsFetcherQuery', (req, res, ctx) => res(ctx.data({
185
+ limits: platformLimiits
186
+ })))
187
+ }
188
+ };
189
+
190
+ function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
191
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
192
+ var FetchRoleBasedChannels = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchRoleBasedChannels" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "limit" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "Int" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "where" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "channels" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "where" }, value: { kind: "Variable", name: { kind: "Name", value: "where" } } }, { kind: "Argument", name: { kind: "Name", value: "limit" }, value: { kind: "Variable", name: { kind: "Name", value: "limit" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "results" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }] } }] } }], loc: { start: 0, end: 210, source: { body: "query FetchRoleBasedChannels($limit: Int!, $where: String!) {\n channels(where: $where, limit: $limit) {\n results {\n id\n key\n nameAllLocales {\n locale\n value\n }\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
193
+ const createFetchStoreDistributionChannelsQueryMock = custom => _objectSpread({
194
+ request: {
195
+ variables: {
196
+ where: `roles contains any ("ProductDistribution")`,
197
+ limit: 500
198
+ },
199
+ query: FetchRoleBasedChannels
200
+ },
201
+ result: {
202
+ data: {
203
+ channels: {
204
+ results: []
205
+ }
206
+ }
207
+ }
208
+ }, custom);
209
+
210
+ exports.createFetchStoreDistributionChannelsQueryMock = createFetchStoreDistributionChannelsQueryMock;
211
+ exports.customFieldDefinitionsMockHanders = handlers$7;
212
+ exports.isFieldDuplicatedMockHandlers = handlers$6;
213
+ exports.platformLimitsMockHandlers = handlers;
214
+ exports.productSelectionsFetcherMockHandler = handlers$5;
215
+ exports.productSelectionsTotalFetcherMockHandler = handlers$4;
216
+ exports.storesListConnectorMockHandlers = handlers$3;
217
+ exports.useStoreByFieldFetcherHandlers = handlers$2;
218
+ exports.useStoresByWherePredicateFetcherHandlers = handlers$1;
219
+ exports.useTotalNumberOfStoresFetcherHandlers = handlers$8;
@@ -0,0 +1,193 @@
1
+ import { graphql } from 'msw';
2
+ import _lastIndexOfInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/last-index-of';
3
+ import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
4
+ import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
5
+ import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
6
+ import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
7
+ import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
8
+ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
9
+ import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
10
+ import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
11
+ import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
12
+ import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
13
+
14
+ const handlers$8 = {
15
+ TotalNumberOfStores: {
16
+ all: total => graphql.query('TotalNumberOfStores', (req, res, ctx) => {
17
+ return res(ctx.data({
18
+ totalNumberOfStores: {
19
+ total
20
+ }
21
+ }));
22
+ })
23
+ }
24
+ };
25
+
26
+ const handlers$7 = {
27
+ TypeDefinitions: {
28
+ all: typeDefinitions => graphql.query('FetchTypeDefinitionsQuery', (req, res, ctx) => res(ctx.data({
29
+ typeDefinitions
30
+ })))
31
+ }
32
+ };
33
+
34
+ const graphqlQueries = {
35
+ ASSOCIATE_ROLE: 'associateRoles',
36
+ ATTRIBUTE_GROUP: 'attributeGroups',
37
+ BUSINESS_UNIT: 'businessUnits',
38
+ CART: 'carts',
39
+ CART_DISCOUNT: 'cartDiscounts',
40
+ CATEGORY: 'categories',
41
+ CHANNEL: 'channels',
42
+ CUSTOMER: 'customers',
43
+ CUSTOMER_GROUP: 'customerGroups',
44
+ DISCOUNT_CODE: 'discountCodes',
45
+ INVENTORY_ENTRY: 'inventoryEntries',
46
+ ORDER: 'orders',
47
+ PAYMENT: 'payments',
48
+ PRODUCT: 'products',
49
+ PRODUCT_DISCOUNT: 'productDiscounts',
50
+ PRODUCT_SELECTION: 'productSelections',
51
+ PRODUCT_TYPE: 'productTypes',
52
+ SHIPPING_METHOD: 'shippingMethods',
53
+ STORE: 'stores',
54
+ TAX_CATEGORY: 'taxCategories',
55
+ ZONE: 'zones'
56
+ };
57
+ const handlers$6 = {
58
+ DuplicatedField: {
59
+ total: (total, resourceType) => graphql.query('FetchResourceTypeDuplicatedField', (req, res, ctx) => {
60
+ if (!graphqlQueries[resourceType]) return res(ctx.data({}));
61
+ return res(ctx.data({
62
+ [graphqlQueries[resourceType]]: {
63
+ total
64
+ }
65
+ }));
66
+ })
67
+ }
68
+ };
69
+
70
+ const handlers$5 = {
71
+ ProductSelections: {
72
+ all: productSelections => graphql.query('FetchProductSelections', (req, res, ctx) => res(ctx.data({
73
+ productSelections
74
+ })))
75
+ }
76
+ };
77
+
78
+ const handlers$4 = {
79
+ ProductSelections: {
80
+ total: total => graphql.query('FetchProductSelectionsTotal', (req, res, ctx) => res(ctx.data({
81
+ productSelections: {
82
+ total,
83
+ __typename: 'ProductSelectionQueryResult'
84
+ }
85
+ })))
86
+ }
87
+ };
88
+
89
+ const extractKeysFromWherePredicateClause = function () {
90
+ let whereClause = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
91
+ return whereClause.substring(_lastIndexOfInstanceProperty(whereClause).call(whereClause, '("') + 1, _lastIndexOfInstanceProperty(whereClause).call(whereClause, '")')).replace(/["]/g, '').split(', ');
92
+ };
93
+ const handlers$3 = {
94
+ StoresList: {
95
+ all: stores => graphql.query('FetchStoresQuery', (req, res, ctx) => {
96
+ // GIVEN req.variables.where is specified
97
+ // THEN return only stores that are being requested (filtering stores based on IDs)
98
+ // ELSE return all the stores (without filtering any)
99
+ if (req.variables.where) {
100
+ var _context;
101
+ const requestedStoreKeys = extractKeysFromWherePredicateClause(req.variables.where);
102
+ const filteredStoreResults = _filterInstanceProperty(_context = stores.results).call(_context, store => _includesInstanceProperty(requestedStoreKeys).call(requestedStoreKeys, store.key));
103
+ return res(ctx.data({
104
+ stores: {
105
+ offset: 0,
106
+ total: filteredStoreResults.length,
107
+ count: filteredStoreResults.length,
108
+ results: filteredStoreResults,
109
+ __typename: 'StoresQueryResult'
110
+ }
111
+ }));
112
+ }
113
+ return res(ctx.data({
114
+ stores
115
+ }));
116
+ }),
117
+ withProductSelections: stores => graphql.query('FetchStoresQuery', (req, res, ctx) => {
118
+ // GIVEN req.variables.where is specified
119
+ // THEN return only stores that are being requested (filtering stores based on IDs)
120
+ // ELSE return all the stores (without filtering any)
121
+ if (req.variables.where) {
122
+ var _context2;
123
+ const requestedStoreKeys = extractKeysFromWherePredicateClause(req.variables.where);
124
+ const filteredStoreResults = _filterInstanceProperty(_context2 = stores.results).call(_context2, store => _includesInstanceProperty(requestedStoreKeys).call(requestedStoreKeys, store.key));
125
+ return res(ctx.data({
126
+ stores: {
127
+ offset: 0,
128
+ total: filteredStoreResults.length,
129
+ count: filteredStoreResults.length,
130
+ results: filteredStoreResults,
131
+ __typename: 'StoresQueryResult'
132
+ }
133
+ }));
134
+ }
135
+ return res(ctx.data({
136
+ stores
137
+ }));
138
+ })
139
+ }
140
+ };
141
+
142
+ const handlers$2 = {
143
+ FetchStoresByField: {
144
+ all: stores => graphql.query('FetchStoresByField', (req, res, ctx) => {
145
+ return res(ctx.data({
146
+ storesByField: stores
147
+ }));
148
+ })
149
+ }
150
+ };
151
+
152
+ const handlers$1 = {
153
+ FetchStoresByWherePredicate: {
154
+ all: stores => graphql.query('FetchStoresByWherePredicate', (req, res, ctx) => {
155
+ return res(ctx.data({
156
+ storesByWherePredicate: {
157
+ results: stores,
158
+ total: stores.length
159
+ }
160
+ }));
161
+ })
162
+ }
163
+ };
164
+
165
+ const handlers = {
166
+ PlatformLimits: {
167
+ all: platformLimiits => graphql.query('PlatformLimitsFetcherQuery', (req, res, ctx) => res(ctx.data({
168
+ limits: platformLimiits
169
+ })))
170
+ }
171
+ };
172
+
173
+ function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
174
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
175
+ var FetchRoleBasedChannels = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchRoleBasedChannels" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "limit" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "Int" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "where" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "channels" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "where" }, value: { kind: "Variable", name: { kind: "Name", value: "where" } } }, { kind: "Argument", name: { kind: "Name", value: "limit" }, value: { kind: "Variable", name: { kind: "Name", value: "limit" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "results" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }] } }] } }], loc: { start: 0, end: 210, source: { body: "query FetchRoleBasedChannels($limit: Int!, $where: String!) {\n channels(where: $where, limit: $limit) {\n results {\n id\n key\n nameAllLocales {\n locale\n value\n }\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
176
+ const createFetchStoreDistributionChannelsQueryMock = custom => _objectSpread({
177
+ request: {
178
+ variables: {
179
+ where: `roles contains any ("ProductDistribution")`,
180
+ limit: 500
181
+ },
182
+ query: FetchRoleBasedChannels
183
+ },
184
+ result: {
185
+ data: {
186
+ channels: {
187
+ results: []
188
+ }
189
+ }
190
+ }
191
+ }, custom);
192
+
193
+ export { createFetchStoreDistributionChannelsQueryMock, handlers$7 as customFieldDefinitionsMockHanders, handlers$6 as isFieldDuplicatedMockHandlers, handlers as platformLimitsMockHandlers, handlers$5 as productSelectionsFetcherMockHandler, handlers$4 as productSelectionsTotalFetcherMockHandler, handlers$3 as storesListConnectorMockHandlers, handlers$2 as useStoreByFieldFetcherHandlers, handlers$1 as useStoresByWherePredicateFetcherHandlers, handlers$8 as useTotalNumberOfStoresFetcherHandlers };
@@ -0,0 +1,4 @@
1
+ {
2
+ "main": "dist/commercetools-frontend-experimental-components-test-utils.cjs.js",
3
+ "module": "dist/commercetools-frontend-experimental-components-test-utils.esm.js"
4
+ }