Skip to content
This repository has been archived by the owner on Jul 7, 2023. It is now read-only.

Commit

Permalink
fix(pluginReducer): add default initialState
Browse files Browse the repository at this point in the history
fixes TypeError when reducer is called with undefined
  • Loading branch information
jedwards1211 committed Mar 22, 2017
1 parent 740cfd4 commit 5bfb033
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redux-plugins-immutable",
"version": "1.2.1",
"version": "1.2.2",
"description": "a powerful app plugin system for redux using immutable state",
"main": "lib/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/pluginReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const selectPluginReducers: (state: Immutable.Map<any, any>) => Reducer = create
)

const pluginReducer: Reducer = composeReducers(
createReducer({
createReducer(Immutable.Map(), {
[ADD_PLUGIN]: (state: Immutable.Map<any, any>, action: Action) => {
let plugin = action.payload
warning(plugin instanceof Immutable.Map, 'plugin must be an Immutable.Map')
Expand Down
3 changes: 3 additions & 0 deletions test/pluginReducerTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import {NOT_LOADED, LOADED} from '../src/pluginTypes'
import {addPlugin, replacePlugin, installPlugin, setPluginStatus} from '../src/pluginActions'

describe('pluginReducer', () => {
it('applies initial state', () => {
expect(pluginReducer(undefined, {type: 'fake'})).toBeDefined()
})
it('works when there are no plugins', () => {
let state = Immutable.Map()
state = pluginReducer(state, {type: 'fake'})
Expand Down

0 comments on commit 5bfb033

Please sign in to comment.