UNPKG

react-remux

Version:
30 lines (26 loc) 928 B
import { mapStateToPropsFactory } from "../../src/utils/mapStateToPropsFactory"; import { createStore } from "remux-core"; const model1 = { namespace: "app1", state: { a: 1 } }; const model2 = { namespace: "app2", state: { b: 1 } }; describe("mapStateToPropsFactory", () => { const store1 = createStore({ model: model1 }); const store2 = createStore({ model: model2 }); it("return own store state", () => { const mapStateToProps = state => state.app1; const enhanceMapStateToProps = mapStateToPropsFactory(mapStateToProps); const state = enhanceMapStateToProps(store1.getState()); expect(state).toEqual({ a: 1 }); }); it("return other store state ", () => { const mapStateToProps = state => state.app2; const enhanceMapStateToProps = mapStateToPropsFactory(mapStateToProps); const state = enhanceMapStateToProps(store1.getState()); expect(state).toEqual({ b: 1 }); }); });