Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import isPlainObject from 'lodash.isplainobject'
const isFunction = arg => typeof arg === 'function'

export function configureStore (middlewares = []) {
return function mockStore (getState = {}) {
return function mockStore (initialState = {}) {
function mockStoreWithoutMiddleware () {
let actions = []
let listeners = []
let state = isFunction(initialState) ? initialState(actions) : initialState
let reducer = () => (state)

const self = {
getState () {
return isFunction(getState) ? getState(actions) : getState
return state
},

getActions () {
Expand Down Expand Up @@ -41,6 +43,7 @@ export function configureStore (middlewares = []) {
listeners[i]()
}

state = reducer(state, action)
return action
},

Expand All @@ -67,6 +70,7 @@ export function configureStore (middlewares = []) {
if (!isFunction(nextReducer)) {
throw new Error('Expected the nextReducer to be a function.')
}
reducer = nextReducer
}
}

Expand Down