Skip to content

Commit

Permalink
Update tests and add changelog entry
Browse files Browse the repository at this point in the history
  • Loading branch information
LPGhatguy committed Aug 8, 2018
1 parent 04ffc53 commit 371bb5c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* The middleware API changed in [#29](https://github.com/Roblox/rodux/pull/29) in a backwards-incompatible way!
* Middleware now run left-to-right instead of right-to-left!
* Errors thrown in `changed` event now have correct stack traces ([#27](https://github.com/Roblox/rodux/pull/27))
* Fixed `createReducer` having incorrect behavior with `nil` state values ([#33](https://github.com/Roblox/rodux/pull/33))

## Public Release (December 13, 2017)
* Initial release!
27 changes: 27 additions & 0 deletions lib/createReducer.spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,33 @@ return function()
expect(newState.b).to.equal(0)
end)

it("should still run action handlers if the state is nil", function()
local callCount = 0

local reducer = createReducer(0, {
foo = function(state, action)
callCount = callCount + 1
return nil
end
})

expect(callCount).to.equal(0)

local newState = reducer(nil, {
type = "foo",
})

expect(callCount).to.equal(1)
expect(newState).to.equal(nil)

newState = reducer(newState, {
type = "foo",
})

expect(callCount).to.equal(2)
expect(newState).to.equal(nil)
end)

it("should return the same state if the action is not handled", function()
local initialState = {
a = 0,
Expand Down

0 comments on commit 371bb5c

Please sign in to comment.