@commercetools-frontend/application-shell-connectors
Version:
Contains complementary tools for @commercetools-frontend/application-shell
55 lines (52 loc) • 5.11 kB
JavaScript
import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
import { GRAPHQL_TARGETS } from '@commercetools-frontend/constants';
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; }
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; }
var FetchProjectExtensionImageRegex = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchProjectExtensionImageRegex" }, variableDefinitions: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "projectExtension" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "imageRegex" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "thumb" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "FragmentSpread", name: { kind: "Name", value: "ImageRegex" }, directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "small" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "FragmentSpread", name: { kind: "Name", value: "ImageRegex" }, directives: [] }] } }] } }] } }] } }, { kind: "FragmentDefinition", name: { kind: "Name", value: "ImageRegex" }, typeCondition: { kind: "NamedType", name: { kind: "Name", value: "ImageRegexOptions" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "flag" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "search" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "replace" }, arguments: [], directives: [] }] } }], loc: { start: 0, end: 256, source: { body: "query FetchProjectExtensionImageRegex {\n projectExtension {\n id\n imageRegex {\n thumb {\n ...ImageRegex\n }\n small {\n ...ImageRegex\n }\n }\n }\n}\nfragment ImageRegex on ImageRegexOptions {\n flag\n search\n replace\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
const createGraphqlResponseForProjectExtensionImageRegexQuery = function () {
let customResponse = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return _objectSpread({
projectExtension: {
__typename: 'ProjectExtension',
id: 'project-extension-id',
imageRegex: {
__typename: 'ImageRegex',
thumb: {
__typename: 'ImageRegexOptions',
flag: 'gi',
replace: '-thumb.jpg',
search: '.[^.]+$'
},
small: {
__typename: 'ImageRegexOptions',
flag: 'gi',
replace: '-small.jpg',
search: '.[^.]+$'
}
}
}
}, customResponse);
};
const createFetchProjectExtensionImageRegexMock = function () {
let customMock = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return _objectSpread({
request: {
query: FetchProjectExtensionImageRegex,
context: {
target: GRAPHQL_TARGETS.SETTINGS_SERVICE
}
},
result: {
data: createGraphqlResponseForProjectExtensionImageRegexQuery()
}
}, customMock);
};
export { createFetchProjectExtensionImageRegexMock, createGraphqlResponseForProjectExtensionImageRegexQuery };