From 2cecbbcad90bce3d57f482e40820a4cf22a103f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20Maa=C3=9F?= <mathiasmaass@gmx.de> Date: Tue, 5 Feb 2019 21:41:32 +0100 Subject: [PATCH] Rename things in the context of fullscreen action. --- __tests__/src/actions/workspace.test.js | 21 ++++++++++++------- __tests__/src/components/App.test.js | 4 ++-- .../WorkspaceFullScreenButton.test.js | 8 +++---- __tests__/src/reducers/workspace.test.js | 8 +++---- src/components/App.js | 10 ++++----- src/components/WorkspaceFullScreenButton.js | 6 +++--- src/containers/App.js | 2 +- src/containers/WorkspaceFullScreenButton.js | 2 +- src/state/actions/action-types.js | 2 +- src/state/actions/workspace.js | 8 +++---- src/state/reducers/workspace.js | 4 ++-- 11 files changed, 41 insertions(+), 34 deletions(-) diff --git a/__tests__/src/actions/workspace.test.js b/__tests__/src/actions/workspace.test.js index b8e74464f..e9de722b9 100644 --- a/__tests__/src/actions/workspace.test.js +++ b/__tests__/src/actions/workspace.test.js @@ -2,15 +2,22 @@ import * as actions from '../../../src/state/actions'; import ActionTypes from '../../../src/state/actions/action-types'; describe('workspace actions', () => { - describe('fullscreenWorkspace', () => { - it('should create a new window with merged defaults', () => { - const options = true; - + describe('setWorkspaceFullscreen', () => { + it('should return correct action type if set to true', () => { + const receivedAction = actions.setWorkspaceFullscreen(true); + const expectedAction = { + type: ActionTypes.SET_WORKSPACE_FULLSCREEN, + isFullscreenEnabled: true, + }; + expect(receivedAction).toEqual(expectedAction); + }); + it('should return correct action type if set to false', () => { + const receivedAction = actions.setWorkspaceFullscreen(false); const expectedAction = { - type: ActionTypes.FULLSCREEN_WORKSPACE, - fullscreen: true, + type: ActionTypes.SET_WORKSPACE_FULLSCREEN, + isFullscreenEnabled: false, }; - expect(actions.fullscreenWorkspace(options)).toEqual(expectedAction); + expect(receivedAction).toEqual(expectedAction); }); }); describe('updateWorkspaceMosaicLayout', () => { diff --git a/__tests__/src/components/App.test.js b/__tests__/src/components/App.test.js index 291e3911c..77bf22bb5 100644 --- a/__tests__/src/components/App.test.js +++ b/__tests__/src/components/App.test.js @@ -9,8 +9,8 @@ describe('App', () => { }); describe('FullScreen', () => { - it('is enabled by the workspace.fullscreen state', () => { - const wrapper = shallow(<App manifests={[]} workspace={{ fullscreen: true }} />); + it('is enabled by the workspace.isFullscreenEnabled state', () => { + const wrapper = shallow(<App manifests={[]} workspace={{ isFullscreenEnabled: true }} />); expect(wrapper.find('FullScreen').first().prop('enabled')).toEqual(true); }); }); diff --git a/__tests__/src/components/WorkspaceFullScreenButton.test.js b/__tests__/src/components/WorkspaceFullScreenButton.test.js index ef49feedb..97e1612c6 100644 --- a/__tests__/src/components/WorkspaceFullScreenButton.test.js +++ b/__tests__/src/components/WorkspaceFullScreenButton.test.js @@ -4,11 +4,11 @@ import WorkspaceFullScreenButton from '../../../src/components/WorkspaceFullScre describe('WorkspaceFullScreenButton', () => { let wrapper; - let fullscreenWorkspace; + let setWorkspaceFullscreen; beforeEach(() => { - fullscreenWorkspace = jest.fn(); + setWorkspaceFullscreen = jest.fn(); wrapper = shallow( - <WorkspaceFullScreenButton classes={{}} fullscreenWorkspace={fullscreenWorkspace} />, + <WorkspaceFullScreenButton classes={{}} setWorkspaceFullscreen={setWorkspaceFullscreen} />, ).dive(); }); @@ -17,6 +17,6 @@ describe('WorkspaceFullScreenButton', () => { }); it('when clicked, sets the fullscreen state', () => { wrapper.find('WithStyles(IconButton)').simulate('click'); - expect(fullscreenWorkspace).toHaveBeenCalledWith(true); + expect(setWorkspaceFullscreen).toHaveBeenCalledWith(true); }); }); diff --git a/__tests__/src/reducers/workspace.test.js b/__tests__/src/reducers/workspace.test.js index 7f80dab51..dd5ebddcb 100644 --- a/__tests__/src/reducers/workspace.test.js +++ b/__tests__/src/reducers/workspace.test.js @@ -10,12 +10,12 @@ describe('workspace reducer', () => { focusedWindowId: 'abc123', }); }); - it('should handle FULLSCREEN_WORKSPACE', () => { + it('should handle SET_WORKSPACE_FULLSCREEN', () => { expect(reducer([], { - type: ActionTypes.FULLSCREEN_WORKSPACE, - fullscreen: true, + type: ActionTypes.SET_WORKSPACE_FULLSCREEN, + isFullscreenEnabled: true, })).toEqual({ - fullscreen: true, + isFullscreenEnabled: true, }); }); it('should handle UPDATE_WORKSPACE_MOSAIC_LAYOUT', () => { diff --git a/src/components/App.js b/src/components/App.js index 153f44580..86b1f1d85 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -16,13 +16,13 @@ class App extends Component { * @return {String} - HTML markup for the component */ render() { - const { workspace, fullscreenWorkspace } = this.props; + const { workspace, setWorkspaceFullscreen } = this.props; return ( <div className={ns('app')}> <CssBaseline /> <Fullscreen - enabled={workspace.fullscreen} - onChange={isFullscreenEnabled => fullscreenWorkspace(isFullscreenEnabled)} + enabled={workspace.isFullscreenEnabled} + onChange={isFullscreenEnabled => setWorkspaceFullscreen(isFullscreenEnabled)} > <Workspace /> </Fullscreen> @@ -34,12 +34,12 @@ class App extends Component { App.propTypes = { workspace: PropTypes.object, // eslint-disable-line react/forbid-prop-types - fullscreenWorkspace: PropTypes.func, + setWorkspaceFullscreen: PropTypes.func, }; App.defaultProps = { workspace: {}, - fullscreenWorkspace: () => {}, + setWorkspaceFullscreen: () => {}, }; export default App; diff --git a/src/components/WorkspaceFullScreenButton.js b/src/components/WorkspaceFullScreenButton.js index c6fb36fc2..2c6a3685b 100644 --- a/src/components/WorkspaceFullScreenButton.js +++ b/src/components/WorkspaceFullScreenButton.js @@ -13,10 +13,10 @@ class WorkspaceFullScreenButton extends Component { * @return */ render() { - const { classes, fullscreenWorkspace } = this.props; + const { classes, setWorkspaceFullscreen } = this.props; return ( <ListItem> - <IconButton className={classes.ctrlBtn} aria-label="Full Screen" onClick={() => fullscreenWorkspace(true)}> + <IconButton className={classes.ctrlBtn} aria-label="Full Screen" onClick={() => setWorkspaceFullscreen(true)}> <FullscreenIcon /> </IconButton> </ListItem> @@ -25,7 +25,7 @@ class WorkspaceFullScreenButton extends Component { } WorkspaceFullScreenButton.propTypes = { - fullscreenWorkspace: PropTypes.func.isRequired, + setWorkspaceFullscreen: PropTypes.func.isRequired, classes: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types }; diff --git a/src/containers/App.js b/src/containers/App.js index 9ad384cc7..dd22661a5 100644 --- a/src/containers/App.js +++ b/src/containers/App.js @@ -22,7 +22,7 @@ const mapStateToProps = state => ( */ const mapDispatchToProps = { fetchManifest: actions.fetchManifest, - fullscreenWorkspace: actions.fullscreenWorkspace, + setWorkspaceFullscreen: actions.setWorkspaceFullscreen, }; const enhance = compose( diff --git a/src/containers/WorkspaceFullScreenButton.js b/src/containers/WorkspaceFullScreenButton.js index e678b5b0c..60ccaa92c 100644 --- a/src/containers/WorkspaceFullScreenButton.js +++ b/src/containers/WorkspaceFullScreenButton.js @@ -8,6 +8,6 @@ import WorkspaceFullScreenButton * @memberof ManifestListItem * @private */ -const mapDispatchToProps = { fullscreenWorkspace: actions.fullscreenWorkspace }; +const mapDispatchToProps = { setWorkspaceFullscreen: actions.setWorkspaceFullscreen }; export default connect(null, mapDispatchToProps)(WorkspaceFullScreenButton); diff --git a/src/state/actions/action-types.js b/src/state/actions/action-types.js index 508692274..946d7ec8d 100644 --- a/src/state/actions/action-types.js +++ b/src/state/actions/action-types.js @@ -1,6 +1,6 @@ const ActionTypes = { FOCUS_WINDOW: 'FOCUS_WINDOW', - FULLSCREEN_WORKSPACE: 'FULLSCREEN_WORKSPACE', + SET_WORKSPACE_FULLSCREEN: 'SET_WORKSPACE_FULLSCREEN', ADD_MANIFEST: 'ADD_MANIFEST', ADD_WINDOW: 'ADD_WINDOW', NEXT_CANVAS: 'NEXT_CANVAS', diff --git a/src/state/actions/workspace.js b/src/state/actions/workspace.js index 331ff96d3..5bda3ff7d 100644 --- a/src/state/actions/workspace.js +++ b/src/state/actions/workspace.js @@ -2,13 +2,13 @@ import ActionTypes from './action-types'; /* eslint-disable import/prefer-default-export */ /** - * fullscreenWorkspace - action creator + * setWorkspaceFullscreen - action creator * - * @param {String} windowId + * @param {Boolean} isFullscreenEnabled * @memberof ActionCreators */ -export function fullscreenWorkspace(fullscreen) { - return { type: ActionTypes.FULLSCREEN_WORKSPACE, fullscreen }; +export function setWorkspaceFullscreen(isFullscreenEnabled) { + return { type: ActionTypes.SET_WORKSPACE_FULLSCREEN, isFullscreenEnabled }; } /** diff --git a/src/state/reducers/workspace.js b/src/state/reducers/workspace.js index 32d2b33de..1bfa069ad 100644 --- a/src/state/reducers/workspace.js +++ b/src/state/reducers/workspace.js @@ -7,8 +7,8 @@ const workspaceReducer = (state = {}, action) => { switch (action.type) { case ActionTypes.FOCUS_WINDOW: return { ...state, focusedWindowId: action.windowId }; - case ActionTypes.FULLSCREEN_WORKSPACE: - return { ...state, fullscreen: action.fullscreen }; + case ActionTypes.SET_WORKSPACE_FULLSCREEN: + return { ...state, isFullscreenEnabled: action.isFullscreenEnabled }; case ActionTypes.UPDATE_WORKSPACE_MOSAIC_LAYOUT: return { ...state, layout: action.layout }; default: -- GitLab