Created
May 23, 2017 11:29
-
-
Save marcusradell/91dafd08836407725e6eb6c4d76ad580 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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