Skip to content
Snippets Groups Projects
Commit 2cecbbca authored by Mathias Maaß's avatar Mathias Maaß
Browse files

Rename things in the context of fullscreen action.

parent b7414c4b
No related branches found
No related tags found
No related merge requests found
...@@ -2,15 +2,22 @@ import * as actions from '../../../src/state/actions'; ...@@ -2,15 +2,22 @@ import * as actions from '../../../src/state/actions';
import ActionTypes from '../../../src/state/actions/action-types'; import ActionTypes from '../../../src/state/actions/action-types';
describe('workspace actions', () => { describe('workspace actions', () => {
describe('fullscreenWorkspace', () => { describe('setWorkspaceFullscreen', () => {
it('should create a new window with merged defaults', () => { it('should return correct action type if set to true', () => {
const options = 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 = { const expectedAction = {
type: ActionTypes.FULLSCREEN_WORKSPACE, type: ActionTypes.SET_WORKSPACE_FULLSCREEN,
fullscreen: true, isFullscreenEnabled: false,
}; };
expect(actions.fullscreenWorkspace(options)).toEqual(expectedAction); expect(receivedAction).toEqual(expectedAction);
}); });
}); });
describe('updateWorkspaceMosaicLayout', () => { describe('updateWorkspaceMosaicLayout', () => {
......
...@@ -9,8 +9,8 @@ describe('App', () => { ...@@ -9,8 +9,8 @@ describe('App', () => {
}); });
describe('FullScreen', () => { describe('FullScreen', () => {
it('is enabled by the workspace.fullscreen state', () => { it('is enabled by the workspace.isFullscreenEnabled state', () => {
const wrapper = shallow(<App manifests={[]} workspace={{ fullscreen: true }} />); const wrapper = shallow(<App manifests={[]} workspace={{ isFullscreenEnabled: true }} />);
expect(wrapper.find('FullScreen').first().prop('enabled')).toEqual(true); expect(wrapper.find('FullScreen').first().prop('enabled')).toEqual(true);
}); });
}); });
......
...@@ -4,11 +4,11 @@ import WorkspaceFullScreenButton from '../../../src/components/WorkspaceFullScre ...@@ -4,11 +4,11 @@ import WorkspaceFullScreenButton from '../../../src/components/WorkspaceFullScre
describe('WorkspaceFullScreenButton', () => { describe('WorkspaceFullScreenButton', () => {
let wrapper; let wrapper;
let fullscreenWorkspace; let setWorkspaceFullscreen;
beforeEach(() => { beforeEach(() => {
fullscreenWorkspace = jest.fn(); setWorkspaceFullscreen = jest.fn();
wrapper = shallow( wrapper = shallow(
<WorkspaceFullScreenButton classes={{}} fullscreenWorkspace={fullscreenWorkspace} />, <WorkspaceFullScreenButton classes={{}} setWorkspaceFullscreen={setWorkspaceFullscreen} />,
).dive(); ).dive();
}); });
...@@ -17,6 +17,6 @@ describe('WorkspaceFullScreenButton', () => { ...@@ -17,6 +17,6 @@ describe('WorkspaceFullScreenButton', () => {
}); });
it('when clicked, sets the fullscreen state', () => { it('when clicked, sets the fullscreen state', () => {
wrapper.find('WithStyles(IconButton)').simulate('click'); wrapper.find('WithStyles(IconButton)').simulate('click');
expect(fullscreenWorkspace).toHaveBeenCalledWith(true); expect(setWorkspaceFullscreen).toHaveBeenCalledWith(true);
}); });
}); });
...@@ -10,12 +10,12 @@ describe('workspace reducer', () => { ...@@ -10,12 +10,12 @@ describe('workspace reducer', () => {
focusedWindowId: 'abc123', focusedWindowId: 'abc123',
}); });
}); });
it('should handle FULLSCREEN_WORKSPACE', () => { it('should handle SET_WORKSPACE_FULLSCREEN', () => {
expect(reducer([], { expect(reducer([], {
type: ActionTypes.FULLSCREEN_WORKSPACE, type: ActionTypes.SET_WORKSPACE_FULLSCREEN,
fullscreen: true, isFullscreenEnabled: true,
})).toEqual({ })).toEqual({
fullscreen: true, isFullscreenEnabled: true,
}); });
}); });
it('should handle UPDATE_WORKSPACE_MOSAIC_LAYOUT', () => { it('should handle UPDATE_WORKSPACE_MOSAIC_LAYOUT', () => {
......
...@@ -16,13 +16,13 @@ class App extends Component { ...@@ -16,13 +16,13 @@ class App extends Component {
* @return {String} - HTML markup for the component * @return {String} - HTML markup for the component
*/ */
render() { render() {
const { workspace, fullscreenWorkspace } = this.props; const { workspace, setWorkspaceFullscreen } = this.props;
return ( return (
<div className={ns('app')}> <div className={ns('app')}>
<CssBaseline /> <CssBaseline />
<Fullscreen <Fullscreen
enabled={workspace.fullscreen} enabled={workspace.isFullscreenEnabled}
onChange={isFullscreenEnabled => fullscreenWorkspace(isFullscreenEnabled)} onChange={isFullscreenEnabled => setWorkspaceFullscreen(isFullscreenEnabled)}
> >
<Workspace /> <Workspace />
</Fullscreen> </Fullscreen>
...@@ -34,12 +34,12 @@ class App extends Component { ...@@ -34,12 +34,12 @@ class App extends Component {
App.propTypes = { App.propTypes = {
workspace: PropTypes.object, // eslint-disable-line react/forbid-prop-types workspace: PropTypes.object, // eslint-disable-line react/forbid-prop-types
fullscreenWorkspace: PropTypes.func, setWorkspaceFullscreen: PropTypes.func,
}; };
App.defaultProps = { App.defaultProps = {
workspace: {}, workspace: {},
fullscreenWorkspace: () => {}, setWorkspaceFullscreen: () => {},
}; };
export default App; export default App;
...@@ -13,10 +13,10 @@ class WorkspaceFullScreenButton extends Component { ...@@ -13,10 +13,10 @@ class WorkspaceFullScreenButton extends Component {
* @return * @return
*/ */
render() { render() {
const { classes, fullscreenWorkspace } = this.props; const { classes, setWorkspaceFullscreen } = this.props;
return ( return (
<ListItem> <ListItem>
<IconButton className={classes.ctrlBtn} aria-label="Full Screen" onClick={() => fullscreenWorkspace(true)}> <IconButton className={classes.ctrlBtn} aria-label="Full Screen" onClick={() => setWorkspaceFullscreen(true)}>
<FullscreenIcon /> <FullscreenIcon />
</IconButton> </IconButton>
</ListItem> </ListItem>
...@@ -25,7 +25,7 @@ class WorkspaceFullScreenButton extends Component { ...@@ -25,7 +25,7 @@ class WorkspaceFullScreenButton extends Component {
} }
WorkspaceFullScreenButton.propTypes = { WorkspaceFullScreenButton.propTypes = {
fullscreenWorkspace: PropTypes.func.isRequired, setWorkspaceFullscreen: PropTypes.func.isRequired,
classes: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types classes: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
}; };
......
...@@ -22,7 +22,7 @@ const mapStateToProps = state => ( ...@@ -22,7 +22,7 @@ const mapStateToProps = state => (
*/ */
const mapDispatchToProps = { const mapDispatchToProps = {
fetchManifest: actions.fetchManifest, fetchManifest: actions.fetchManifest,
fullscreenWorkspace: actions.fullscreenWorkspace, setWorkspaceFullscreen: actions.setWorkspaceFullscreen,
}; };
const enhance = compose( const enhance = compose(
......
...@@ -8,6 +8,6 @@ import WorkspaceFullScreenButton ...@@ -8,6 +8,6 @@ import WorkspaceFullScreenButton
* @memberof ManifestListItem * @memberof ManifestListItem
* @private * @private
*/ */
const mapDispatchToProps = { fullscreenWorkspace: actions.fullscreenWorkspace }; const mapDispatchToProps = { setWorkspaceFullscreen: actions.setWorkspaceFullscreen };
export default connect(null, mapDispatchToProps)(WorkspaceFullScreenButton); export default connect(null, mapDispatchToProps)(WorkspaceFullScreenButton);
const ActionTypes = { const ActionTypes = {
FOCUS_WINDOW: 'FOCUS_WINDOW', FOCUS_WINDOW: 'FOCUS_WINDOW',
FULLSCREEN_WORKSPACE: 'FULLSCREEN_WORKSPACE', SET_WORKSPACE_FULLSCREEN: 'SET_WORKSPACE_FULLSCREEN',
ADD_MANIFEST: 'ADD_MANIFEST', ADD_MANIFEST: 'ADD_MANIFEST',
ADD_WINDOW: 'ADD_WINDOW', ADD_WINDOW: 'ADD_WINDOW',
NEXT_CANVAS: 'NEXT_CANVAS', NEXT_CANVAS: 'NEXT_CANVAS',
......
...@@ -2,13 +2,13 @@ import ActionTypes from './action-types'; ...@@ -2,13 +2,13 @@ import ActionTypes from './action-types';
/* eslint-disable import/prefer-default-export */ /* eslint-disable import/prefer-default-export */
/** /**
* fullscreenWorkspace - action creator * setWorkspaceFullscreen - action creator
* *
* @param {String} windowId * @param {Boolean} isFullscreenEnabled
* @memberof ActionCreators * @memberof ActionCreators
*/ */
export function fullscreenWorkspace(fullscreen) { export function setWorkspaceFullscreen(isFullscreenEnabled) {
return { type: ActionTypes.FULLSCREEN_WORKSPACE, fullscreen }; return { type: ActionTypes.SET_WORKSPACE_FULLSCREEN, isFullscreenEnabled };
} }
/** /**
......
...@@ -7,8 +7,8 @@ const workspaceReducer = (state = {}, action) => { ...@@ -7,8 +7,8 @@ const workspaceReducer = (state = {}, action) => {
switch (action.type) { switch (action.type) {
case ActionTypes.FOCUS_WINDOW: case ActionTypes.FOCUS_WINDOW:
return { ...state, focusedWindowId: action.windowId }; return { ...state, focusedWindowId: action.windowId };
case ActionTypes.FULLSCREEN_WORKSPACE: case ActionTypes.SET_WORKSPACE_FULLSCREEN:
return { ...state, fullscreen: action.fullscreen }; return { ...state, isFullscreenEnabled: action.isFullscreenEnabled };
case ActionTypes.UPDATE_WORKSPACE_MOSAIC_LAYOUT: case ActionTypes.UPDATE_WORKSPACE_MOSAIC_LAYOUT:
return { ...state, layout: action.layout }; return { ...state, layout: action.layout };
default: default:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment