UNPKG

@talend/react-cmf

Version:

A framework built on top of best react libraries

78 lines 1.56 kB
import settings from './settings'; import collections from './collections'; import components from './components'; import { cloneDeep } from "lodash"; import { jsx as _jsx } from "react/jsx-runtime"; const state = { cmf: { settings, collections, components } }; 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__*/_jsx("div", { children: "mock" }), 'actionCreator:myactionCreator': () => {} }; const context = { store, registry }; const emptyContext = { store: { getState() { return notInitializedState; } } }; function copy(obj) { return 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), store: myState => { const myStore = copy(store); if (myState) { myStore.getState = () => myState; } return myStore; } }; export default mock; //# sourceMappingURL=store.js.map