From 5a1d94ed69732a118ee540a4535907e6eb6e9f7a Mon Sep 17 00:00:00 2001 From: Jorgen Evens Date: Tue, 26 Apr 2016 23:18:33 +0200 Subject: [PATCH 1/3] Fix state after returning new state object from reduce. --- src/store/AltStore.js | 2 +- test/functional-test.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/store/AltStore.js b/src/store/AltStore.js index c2e70cdd..9557d0c6 100644 --- a/src/store/AltStore.js +++ b/src/store/AltStore.js @@ -72,7 +72,7 @@ class AltStore { if (model.reduce) { handleDispatch(() => { const value = model.reduce(this.state, payload) - if (value !== undefined) this.state = value + if (value !== undefined) this.state = model.state = value }, payload) if (!this.preventDefault) this.emitChange() } diff --git a/test/functional-test.js b/test/functional-test.js index d766c999..9b0c41fb 100644 --- a/test/functional-test.js +++ b/test/functional-test.js @@ -171,5 +171,24 @@ export default { assert(store.reduce(store.state).x === 0) assert(store2.reduce(store2.state).x === 1) }, + + 'state returned from reduce is set correctly'() { + const alt = new Alt() + const actions = alt.generateActions('test'); + + const store = alt.createStore({ + displayName: 'store', + + state: { x: 0 }, + + reduce(state) { + assert(state === this.state, 'state matches this.state'); + return { ...state }; + } + }) + + actions.test(); + actions.test(); + }, } } From d494a25aafa64d97d1273ed00627042ce6b67f92 Mon Sep 17 00:00:00 2001 From: Jorgen Evens Date: Tue, 26 Apr 2016 23:41:23 +0200 Subject: [PATCH 2/3] Add node 5.11 to the list of engines to test on. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index be3e1586..97422cb9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,5 @@ language: node_js script: npm run lint && npm run coverage after_script: cat ./coverage/lcov.info | coveralls node_js: + - "5.11" - "stable" From d266350f776d66a446d850f9818d9d58faab8c8e Mon Sep 17 00:00:00 2001 From: Jorgen Evens Date: Tue, 12 Jul 2016 16:29:25 +0200 Subject: [PATCH 3/3] Update babel to fix tests on node v6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index efea2be6..6e62c5b9 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ }, "devDependencies": { "alt-search-docs": "1.0.6", - "babel-cli": "6.6.5", + "babel-cli": "6.7.7", "babel-core": "6.7.4", "babel-eslint": "5.0.0", "babel-loader": "6.2.4",