Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
5 changes: 2 additions & 3 deletions generators/container/reducer.js.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
*
*/
import produce from 'immer'
import { fromJS } from 'immutable'
import { createActions } from 'reduxsauce'

export const initialState = fromJS({})
export const initialState = {}

export const { Types: {{ camelCase name }}Types, Creators: {{ camelCase name }}Creators } = createActions({
defaultAction: ['somePayload']
Expand All @@ -18,7 +17,7 @@ export const {{ camelCase name }}Reducer = (state = initialState, action) =>
produce(state, (/* draft */) => {
switch (action.type) {
case {{ camelCase name}}Types.DEFAULT_ACTION:
return state.set('somePayload', action.somePayload)
return {...state, somePayload: action.somePayload}
default:
return state
}
Expand Down
3 changes: 1 addition & 2 deletions generators/container/reducer.test.js.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// import produce from 'immer'
import { fromJS } from 'immutable';
import { {{ camelCase name }}Reducer, {{ camelCase name }}Types, initialState } from '../reducer'

/* eslint-disable default-case, no-param-reassign */
Expand All @@ -14,7 +13,7 @@ describe('{{ properCase name }} reducer tests', () => {
})

it('should return the update the state when an action of type DEFAULT is dispatched', () => {
const expectedResult = fromJS(state.toJS()).set('somePayload', 'Mohammed Ali Chherawalla')
const expectedResult = {...state, somePayload: 'Mohammed Ali Chherawalla'}
expect(
{{ camelCase name }}Reducer(state, {
type: {{ camelCase name}}Types.DEFAULT_ACTION,
Expand Down
2 changes: 1 addition & 1 deletion generators/container/selectors.js.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { initialState } from './reducer'
* Direct selector to the {{ camelCase name }} state domain
*/

const select{{ properCase name }}Domain = state => (state.{{ camelCase name }} || initialState).toJS()
const select{{ properCase name }}Domain = state => state.{{ camelCase name }} || initialState

const makeSelect{{ properCase name }} = () =>
createSelector(select{{ properCase name }}Domain, substate => substate)
Expand Down
5 changes: 2 additions & 3 deletions generators/container/selectors.test.js.hbs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { fromJS } from 'immutable'
import { select{{ properCase name }}Domain } from '../selectors'

describe('{{ properCase name }} selector tests', () => {
let mockedState

beforeEach(() => {
mockedState = {
{{ camelCase name }}: fromJS({})
{{ camelCase name }}: {}
}
})

it('should select the user state', () => {
expect(select{{ properCase name }}Domain(mockedState)).toEqual(mockedState.{{ camelCase name }}.toJS())
expect(select{{ properCase name }}Domain(mockedState)).toEqual(mockedState.{{ camelCase name }})
})
})