UNPKG

@talend/react-cmf

Version:

A framework built on top of best react libraries

85 lines (84 loc) 1.95 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _settings = _interopRequireDefault(require("./settings")); var _collections = _interopRequireDefault(require("./collections")); var _components = _interopRequireDefault(require("./components")); var _lodash = require("lodash"); var _jsxRuntime = require("react/jsx-runtime"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } const state = { cmf: { settings: _settings.default, collections: _collections.default, components: _components.default } }; const notInitializedState = { initialized: false, cmf: { settings: { contentTypes: {}, actions: {}, views: {}, props: {} } } }; const store = { getState() { return state; }, dispatch() { return 'dispatch'; }, subscribe() {} }; const registry = { '_.route.component:component': () => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", { children: "mock" }), 'actionCreator:myactionCreator': () => {} }; const context = { store, registry }; const emptyContext = { store: { getState() { return notInitializedState; } } }; function copy(obj) { return (0, _lodash.cloneDeep)(obj); } const mock = { context: (myState, myRegistry) => { const myContext = copy(context); if (myState) { myContext.store.getState = () => myState; } if (myRegistry) { myContext.registry = myRegistry; } return myContext; }, emptyContext: () => copy(emptyContext), notInitializedState: () => copy(notInitializedState), registry: () => copy(registry), state: () => copy(state), settings: () => copy(_settings.default), store: myState => { const myStore = copy(store); if (myState) { myStore.getState = () => myState; } return myStore; } }; var _default = exports.default = mock; //# sourceMappingURL=store.js.map