@commercetools-frontend/experimental-components 6.2.1 → 6.2.3

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,202 @@
1
+ import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
2
+ import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
3
+ import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
4
+ import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
5
+ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
6
+ import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
7
+ import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
8
+ import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
9
+ import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
10
+ import { graphql } from 'msw';
11
+ import _lastIndexOfInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/last-index-of';
12
+ import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
13
+
14
+ const handlers$g = {
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
+ var handlers$h = handlers$g;
26
+
27
+ const handlers$e = {
28
+ TypeDefinitions: {
29
+ all: typeDefinitions => graphql.query('FetchTypeDefinitionsQuery', (req, res, ctx) => res(ctx.data({
30
+ typeDefinitions
31
+ })))
32
+ }
33
+ };
34
+ var handlers$f = handlers$e;
35
+
36
+ const graphqlQueries = {
37
+ ASSOCIATE_ROLE: 'associateRoles',
38
+ ATTRIBUTE_GROUP: 'attributeGroups',
39
+ BUSINESS_UNIT: 'businessUnits',
40
+ CART: 'carts',
41
+ CART_DISCOUNT: 'cartDiscounts',
42
+ CATEGORY: 'categories',
43
+ CHANNEL: 'channels',
44
+ CUSTOMER: 'customers',
45
+ CUSTOMER_GROUP: 'customerGroups',
46
+ DISCOUNT_CODE: 'discountCodes',
47
+ INVENTORY_ENTRY: 'inventoryEntries',
48
+ ORDER: 'orders',
49
+ PAYMENT: 'payments',
50
+ PRODUCT: 'products',
51
+ PRODUCT_DISCOUNT: 'productDiscounts',
52
+ PRODUCT_SELECTION: 'productSelections',
53
+ PRODUCT_TYPE: 'productTypes',
54
+ SHIPPING_METHOD: 'shippingMethods',
55
+ STORE: 'stores',
56
+ TAX_CATEGORY: 'taxCategories',
57
+ ZONE: 'zones'
58
+ };
59
+ const handlers$c = {
60
+ DuplicatedField: {
61
+ total: (total, resourceType) => graphql.query('FetchResourceTypeDuplicatedField', (req, res, ctx) => {
62
+ if (!graphqlQueries[resourceType]) return res(ctx.data({}));
63
+ return res(ctx.data({
64
+ [graphqlQueries[resourceType]]: {
65
+ total
66
+ }
67
+ }));
68
+ })
69
+ }
70
+ };
71
+ var handlers$d = handlers$c;
72
+
73
+ const handlers$a = {
74
+ ProductSelections: {
75
+ all: productSelections => graphql.query('FetchProductSelections', (req, res, ctx) => res(ctx.data({
76
+ productSelections
77
+ })))
78
+ }
79
+ };
80
+ var handlers$b = handlers$a;
81
+
82
+ const handlers$8 = {
83
+ ProductSelections: {
84
+ total: total => graphql.query('FetchProductSelectionsTotal', (req, res, ctx) => res(ctx.data({
85
+ productSelections: {
86
+ total,
87
+ __typename: 'ProductSelectionQueryResult'
88
+ }
89
+ })))
90
+ }
91
+ };
92
+ var handlers$9 = handlers$8;
93
+
94
+ const extractKeysFromWherePredicateClause = function () {
95
+ let whereClause = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
96
+ return whereClause.substring(_lastIndexOfInstanceProperty(whereClause).call(whereClause, '("') + 1, _lastIndexOfInstanceProperty(whereClause).call(whereClause, '")')).replace(/["]/g, '').split(', ');
97
+ };
98
+ const handlers$6 = {
99
+ StoresList: {
100
+ all: stores => graphql.query('FetchStoresQuery', (req, res, ctx) => {
101
+ // GIVEN req.variables.where is specified
102
+ // THEN return only stores that are being requested (filtering stores based on IDs)
103
+ // ELSE return all the stores (without filtering any)
104
+ if (req.variables.where) {
105
+ var _context;
106
+ const requestedStoreKeys = extractKeysFromWherePredicateClause(req.variables.where);
107
+ const filteredStoreResults = _filterInstanceProperty(_context = stores.results).call(_context, store => _includesInstanceProperty(requestedStoreKeys).call(requestedStoreKeys, store.key));
108
+ return res(ctx.data({
109
+ stores: {
110
+ offset: 0,
111
+ total: filteredStoreResults.length,
112
+ count: filteredStoreResults.length,
113
+ results: filteredStoreResults,
114
+ __typename: 'StoresQueryResult'
115
+ }
116
+ }));
117
+ }
118
+ return res(ctx.data({
119
+ stores
120
+ }));
121
+ }),
122
+ withProductSelections: stores => graphql.query('FetchStoresQuery', (req, res, ctx) => {
123
+ // GIVEN req.variables.where is specified
124
+ // THEN return only stores that are being requested (filtering stores based on IDs)
125
+ // ELSE return all the stores (without filtering any)
126
+ if (req.variables.where) {
127
+ var _context2;
128
+ const requestedStoreKeys = extractKeysFromWherePredicateClause(req.variables.where);
129
+ const filteredStoreResults = _filterInstanceProperty(_context2 = stores.results).call(_context2, store => _includesInstanceProperty(requestedStoreKeys).call(requestedStoreKeys, store.key));
130
+ return res(ctx.data({
131
+ stores: {
132
+ offset: 0,
133
+ total: filteredStoreResults.length,
134
+ count: filteredStoreResults.length,
135
+ results: filteredStoreResults,
136
+ __typename: 'StoresQueryResult'
137
+ }
138
+ }));
139
+ }
140
+ return res(ctx.data({
141
+ stores
142
+ }));
143
+ })
144
+ }
145
+ };
146
+ var handlers$7 = handlers$6;
147
+
148
+ const handlers$4 = {
149
+ FetchStoresByField: {
150
+ all: stores => graphql.query('FetchStoresByField', (req, res, ctx) => {
151
+ return res(ctx.data({
152
+ storesByField: stores
153
+ }));
154
+ })
155
+ }
156
+ };
157
+ var handlers$5 = handlers$4;
158
+
159
+ const handlers$2 = {
160
+ FetchStoresByWherePredicate: {
161
+ all: stores => graphql.query('FetchStoresByWherePredicate', (req, res, ctx) => {
162
+ return res(ctx.data({
163
+ storesByWherePredicate: {
164
+ results: stores,
165
+ total: stores.length
166
+ }
167
+ }));
168
+ })
169
+ }
170
+ };
171
+ var handlers$3 = handlers$2;
172
+
173
+ const handlers = {
174
+ PlatformLimits: {
175
+ all: platformLimiits => graphql.query('PlatformLimitsFetcherQuery', (req, res, ctx) => res(ctx.data({
176
+ limits: platformLimiits
177
+ })))
178
+ }
179
+ };
180
+ var handlers$1 = handlers;
181
+
182
+ 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; }
183
+ 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; }
184
+ 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 } } } };
185
+ const createFetchStoreDistributionChannelsQueryMock = custom => _objectSpread({
186
+ request: {
187
+ variables: {
188
+ where: `roles contains any ("ProductDistribution")`,
189
+ limit: 500
190
+ },
191
+ query: FetchRoleBasedChannels
192
+ },
193
+ result: {
194
+ data: {
195
+ channels: {
196
+ results: []
197
+ }
198
+ }
199
+ }
200
+ }, custom);
201
+
202
+ export { createFetchStoreDistributionChannelsQueryMock, handlers$f as customFieldDefinitionsMockHanders, handlers$d as isFieldDuplicatedMockHandlers, handlers$1 as platformLimitsMockHandlers, handlers$b as productSelectionsFetcherMockHandler, handlers$9 as productSelectionsTotalFetcherMockHandler, handlers$7 as storesListConnectorMockHandlers, handlers$5 as useStoreByFieldFetcherHandlers, handlers$3 as useStoresByWherePredicateFetcherHandlers, handlers$h 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
+ }