Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(editor-reducers): add test for editor context-reducer
Required extracting some action type definitions to separate files to avoid pulling in code that depends on a browser environment.
- Loading branch information
1 parent
dc75720
commit 6dc32cd
Showing
9 changed files
with
109 additions
and
41 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
server/zanata-frontend/src/frontend/app/editor/actions/action-types.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const ROUTING_PARAMS_CHANGED = Symbol('ROUTING_PARAMS_CHANGED') | ||
export const SET_SIDEBAR_VISIBILITY = Symbol('SET_SIDEBAR_VISIBILITY') |
10 changes: 10 additions & 0 deletions
10
server/zanata-frontend/src/frontend/app/editor/actions/header-action-types.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export const TOGGLE_GLOSSARY = Symbol('TOGGLE_GLOSSARY') | ||
export const TOGGLE_HEADER = Symbol('TOGGLE_HEADER') | ||
export const TOGGLE_KEY_SHORTCUTS = Symbol('TOGGLE_KEY_SHORTCUTS') | ||
export const FETCH_FAILED = Symbol('FETCH_FAILED') | ||
export const UI_LOCALES_FETCHED = Symbol('UI_LOCALES_FETCHED') | ||
export const CHANGE_UI_LOCALE = Symbol('CHANGE_UI_LOCALE') | ||
export const DOCUMENT_SELECTED = Symbol('DOCUMENT_SELECTED') | ||
export const LOCALE_SELECTED = Symbol('LOCALE_SELECTED') | ||
export const STATS_FETCHED = Symbol('STATS_FETCHED') | ||
export const HEADER_DATA_FETCHED = Symbol('HEADER_DATA_FETCHED') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
server/zanata-frontend/src/frontend/app/editor/actions/suggestions-action-types.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export const TOGGLE_SUGGESTIONS = Symbol('TOGGLE_SUGGESTIONS') | ||
export const DIFF_SETTING_CHANGED = Symbol('DIFF_SETTING_CHANGED') | ||
export const SET_SUGGESTION_SEARCH_TYPE = Symbol('SET_SUGGESTION_SEARCH_TYPE') | ||
export const RESET_SUGGESTIONS_COPYING = Symbol('RESET_SUGGESTIONS_COPYING') | ||
// FIXME may be unused | ||
export const COPY_SUGGESTION_N = Symbol('COPY_SUGGESTION_N') | ||
export const COPY_SUGGESTION = Symbol('COPY_SUGGESTION') | ||
export const TEXT_SUGGESTION_STARTED_COPYING = | ||
Symbol('TEXT_SUGGESTION_STARTED_COPYING') | ||
export const TEXT_SUGGESTION_FINISHED_COPYING = | ||
Symbol('TEXT_SUGGESTION_FINISHED_COPYING') | ||
export const PHRASE_SUGGESTION_STARTED_COPYING = | ||
Symbol('PHRASE_SUGGESTION_STARTED_COPYING') | ||
export const PHRASE_SUGGESTION_FINISHED_COPYING = | ||
Symbol('PHRASE_SUGGESTION_FINISHED_COPYING') | ||
export const TEXT_SUGGESTIONS_UPDATED = Symbol('TEXT_SUGGESTIONS_UPDATED') | ||
export const SUGGESTION_SEARCH_TEXT_CHANGE = | ||
Symbol('SUGGESTION_SEARCH_TEXT_CHANGE') | ||
export const PHRASE_SUGGESTIONS_UPDATED = Symbol('PHRASE_SUGGESTIONS_UPDATED') | ||
export const SUGGESTION_PANEL_HEIGHT_CHANGE = | ||
Symbol('SUGGESTION_PANEL_HEIGHT_CHANGE') | ||
export const SHOW_DETAIL_FOR_SUGGESTION_BY_INDEX = | ||
Symbol('SHOW_DETAIL_FOR_SUGGESTION_BY_INDEX') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
server/zanata-frontend/src/frontend/app/editor/reducers/context-reducer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
server/zanata-frontend/src/frontend/app/editor/reducers/context-reducer.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
jest.disableAutomock() | ||
|
||
import contextReducer from './context-reducer' | ||
import { ROUTING_PARAMS_CHANGED } from '../actions/action-types' | ||
import { DEFAULT_LOCALE } from './ui-reducer' | ||
|
||
describe('context-reducer test', () => { | ||
it('generates initial state', () => { | ||
const initial = contextReducer(undefined, { type: 'an action' }) | ||
expect(initial).toEqual({ | ||
sourceLocale: DEFAULT_LOCALE | ||
}) | ||
}) | ||
|
||
it('merges in new routing params', () => { | ||
const initial = { | ||
sourceLocale: DEFAULT_LOCALE, | ||
a: 'a', | ||
b: 'b', | ||
c: 'c' | ||
} | ||
const updated = contextReducer(initial, { | ||
type: ROUTING_PARAMS_CHANGED, | ||
// Note: the reducer does not check for valid internal structure of params | ||
params: { | ||
a: 'a', | ||
b: 'B', | ||
d: 'd' | ||
} | ||
}) | ||
expect(updated).toEqual({ | ||
sourceLocale: DEFAULT_LOCALE, | ||
a: 'a', | ||
b: 'B', | ||
c: 'c', | ||
d: 'd' | ||
}) | ||
}) | ||
}) |
6 changes: 3 additions & 3 deletions
6
server/zanata-frontend/src/frontend/app/editor/reducers/ui-reducer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters