Skip to content

Commit

Permalink
refactor(actions): make OPEN_DROPDOWN and CLOSE_DROPDOWN FSAs
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmason committed Sep 22, 2017
1 parent 5b30563 commit bdc9b1a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
@@ -1,5 +1,5 @@
export const ROUTING_PARAMS_CHANGED = 'ROUTING_PARAMS_CHANGED'
export const SET_SIDEBAR_VISIBILITY = 'SET_SIDEBAR_VISIBILITY'
export const TOGGLE_DROPDOWN = 'TOGGLE_DROPDOWN'
export const OPEN_DROPDOWN = Symbol('OPEN_DROPDOWN')
export const CLOSE_DROPDOWN = Symbol('CLOSE_DROPDOWN')
export const OPEN_DROPDOWN = 'OPEN_DROPDOWN'
export const CLOSE_DROPDOWN = 'CLOSE_DROPDOWN'
10 changes: 2 additions & 8 deletions server/zanata-frontend/src/frontend/app/editor/actions/index.js
Expand Up @@ -14,14 +14,8 @@ export const routingParamsChanged = createAction(ROUTING_PARAMS_CHANGED)
* Every dropdown should have a reference-unique key.
*/
export const toggleDropdown = createAction(TOGGLE_DROPDOWN)

export function openDropdown (dropdownKey) {
return { type: OPEN_DROPDOWN, key: dropdownKey }
}

export function closeDropdown () {
return { type: CLOSE_DROPDOWN }
}
export const openDropdown = createAction(OPEN_DROPDOWN)
export const closeDropdown = createAction(CLOSE_DROPDOWN)

/**
* Fetch the list of documents for the current project-version
Expand Down
Expand Up @@ -18,7 +18,7 @@ const dropdownReducer = (state = defaultState, action) => {
switch (action.type) {
case OPEN_DROPDOWN:
return update({
openDropdownKey: {$set: action.key}
openDropdownKey: {$set: action.payload}
})

case CLOSE_DROPDOWN:
Expand Down
Expand Up @@ -26,15 +26,15 @@ describe('dropdown-reducer test', () => {
const initial = dropdownReducer(undefined, { type: 'any' })
const localeOpen = dropdownReducer(initial, {
type: OPEN_DROPDOWN,
key: initial.localeKey
payload: initial.localeKey
})
expect(localeOpen).toEqual(expect.objectContaining({
openDropdownKey: initial.localeKey
}))

expect(dropdownReducer(localeOpen, {
type: OPEN_DROPDOWN,
key: initial.docsKey
payload: initial.docsKey
})).toEqual(expect.objectContaining({
openDropdownKey: initial.docsKey
}))
Expand All @@ -44,7 +44,7 @@ describe('dropdown-reducer test', () => {
const initial = dropdownReducer(undefined, { type: 'any' })
const localeOpen = dropdownReducer(initial, {
type: OPEN_DROPDOWN,
key: initial.localeKey
payload: initial.localeKey
})
expect(dropdownReducer(localeOpen, {
type: CLOSE_DROPDOWN
Expand Down

0 comments on commit bdc9b1a

Please sign in to comment.