Skip to content

Commit

Permalink
refactor(actions): simplify payload of SHOW_GLOSSARY_DETAILS
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmason committed Sep 22, 2017
1 parent b5c9122 commit 0d396fb
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
Expand Up @@ -11,7 +11,7 @@ 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 = 'SET_GLOSSARY_DETAILS_INDEX'
/* Set whether glossary details modal is showing */
export const SHOW_GLOSSARY_DETAILS = Symbol('SHOW_GLOSSARY_DETAILS')
export const SHOW_GLOSSARY_DETAILS = 'SHOW_GLOSSARY_DETAILS'

/* API request for glossary details has started. */
export const GLOSSARY_DETAILS_REQUEST = Symbol('GLOSSARY_DETAILS_REQUEST')
Expand Down
Expand Up @@ -105,13 +105,7 @@ function findGlossaryTerms (searchText) {
}

const setGlossaryDetailsIndex = createAction(SET_GLOSSARY_DETAILS_INDEX)

export function showGlossaryDetails (show) {
return {
type: SHOW_GLOSSARY_DETAILS,
payload: { show }
}
}
export const showGlossaryDetails = createAction(SHOW_GLOSSARY_DETAILS)

/**
* Show the glossary details modal and fetch details from the API.
Expand Down
Expand Up @@ -111,7 +111,7 @@ const glossary = (state = defaultState, action) => {
case SHOW_GLOSSARY_DETAILS:
return update({
details: {
show: {$set: action.payload.show}
show: {$set: action.payload}
}
})

Expand Down
Expand Up @@ -206,11 +206,11 @@ describe('glossary-reducer test', () => {
const initial = glossaryReducer(undefined, { type: 'any' })
const shown = glossaryReducer(initial, {
type: SHOW_GLOSSARY_DETAILS,
payload: { show: true }
payload: true
})
const hidden = glossaryReducer(shown, {
type: SHOW_GLOSSARY_DETAILS,
payload: { show: false }
payload: false
})
expect(initial.details.show).toEqual(false)
expect(shown.details.show).toEqual(true)
Expand Down

0 comments on commit 0d396fb

Please sign in to comment.