Skip to content

Commit

Permalink
refactor(actions): simplify payload of SET_GLOSSARY_DETAILS_INDEX
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmason committed Sep 22, 2017
1 parent 184d6ea commit b5c9122
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 11 deletions.
Expand Up @@ -9,7 +9,7 @@ export const GLOSSARY_TERMS_SUCCESS = 'GLOSSARY_TERMS_SUCCESS'
export const GLOSSARY_TERMS_FAILURE = 'GLOSSARY_TERMS_FAILURE'

/* Indicates the index in glossary results that should have details displayed */
export const SET_GLOSSARY_DETAILS_INDEX = Symbol('SET_GLOSSARY_DETAILS_INDEX')
export const SET_GLOSSARY_DETAILS_INDEX = 'SET_GLOSSARY_DETAILS_INDEX'
/* Set whether glossary details modal is showing */
export const SHOW_GLOSSARY_DETAILS = Symbol('SHOW_GLOSSARY_DETAILS')

Expand Down
Expand Up @@ -104,12 +104,7 @@ function findGlossaryTerms (searchText) {
}
}

function setGlossaryDetailsIndex (index) {
return {
type: SET_GLOSSARY_DETAILS_INDEX,
payload: { index }
}
}
const setGlossaryDetailsIndex = createAction(SET_GLOSSARY_DETAILS_INDEX)

export function showGlossaryDetails (show) {
return {
Expand Down
Expand Up @@ -104,7 +104,7 @@ const glossary = (state = defaultState, action) => {
case SET_GLOSSARY_DETAILS_INDEX:
return update({
details: {
resultIndex: {$set: action.payload.index}
resultIndex: {$set: action.payload}
}
})

Expand Down
Expand Up @@ -196,9 +196,7 @@ describe('glossary-reducer test', () => {
const initial = glossaryReducer(undefined, { type: 'any' })
const withIndex = glossaryReducer(initial, {
type: SET_GLOSSARY_DETAILS_INDEX,
payload: {
index: 5
}
payload: 5
})
expect(initial.details.resultIndex).toEqual(0)
expect(withIndex.details.resultIndex).toEqual(5)
Expand Down

0 comments on commit b5c9122

Please sign in to comment.