diff --git a/__tests__/src/actions/workspace.test.js b/__tests__/src/actions/workspace.test.js index b8e74464fc08637f0588007cd52282828d1cfb29..e9de722b9d23d88d97ec051510ea6abc0f83fc8f 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 291e3911c61626de7e36c430fb7286784332b98c..77bf22bb5c09ced33816758d39402a94461d8371 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 ef49feedb0d07547803aaa9dac5096f4e012428d..97e1612c65a8109334c5b49bee49b3ae71f58dc8 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 7f80dab51600d2665081e21bb1c895e5c79e7dd4..dd5ebddcb99bc540ffd0ae87f4d99a5dbd8568ab 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 153f4458089ddba80ffc4f11b2ea080ac28fed52..86b1f1d8550e0d369391937839595f7fdf7c3082 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 c6fb36fc212d748eb9ef618e9002cbd9ddb7dc42..2c6a3685bb5a3aafb442a1699877736a250b0e17 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 9ad384cc763121a26abd2f29d6521bbd6cceb3f9..dd22661a5eea6af1fd5b908b38e069cb1ce22124 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 e678b5b0c41e4b429bccfedefdbf1946ad0448cb..60ccaa92c4331f6129ffd9b50595c01f656255dd 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 50869227446a4af8ac34f903b91d48e2e710df3b..946d7ec8df813a86d04a53452c175f1e50015444 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 331ff96d3bccad0c6089875f90f2c2ba3c4aec1f..5bda3ff7df4303e90799ecce67194cd74ea4f3bf 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 32d2b33de1335fcba4b68922bd8aa3b4b6ccd8ec..1bfa069ad2d15d1448033771ee55c1c8e2da122a 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: