Skip to content

Instantly share code, notes, and snippets.

@marcusradell
Created May 23, 2017 11:29
Show Gist options
  • Save marcusradell/91dafd08836407725e6eb6c4d76ad580 to your computer and use it in GitHub Desktop.
Save marcusradell/91dafd08836407725e6eb6c4d76ad580 to your computer and use it in GitHub Desktop.
test("connectModel epics", () => {
const initialState = {
value: "initial",
loading: null
};
const updaters = {};
const epics = {
loadValue: {
actionUpdater: () => state => Object.assign({}, state, { loading: true }),
successUpdater: value => state =>
Object.assign({}, state, { loading: false, value }),
errorUpdater: () => () => null,
service: () => Promise.resolve({ data: "new promised value" })
}
};
const connectedModel = connectModel({ initialState, updaters, epics });
const expectationPromise = connectedModel.stateStream
.skip(2)
.take(1)
.forEach(state => {
expect(state).toEqual({ value: "new promised value", loading: false });
});
connectedModel.actions.loadValue();
return expectationPromise;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment