diff --git a/test/unit/reducers/mode-reducer.test.js b/test/unit/reducers/mode-reducer.test.js new file mode 100644 index 0000000000000000000000000000000000000000..8b57f8a35012dc51ffef6b9616df357cb9e09a8d --- /dev/null +++ b/test/unit/reducers/mode-reducer.test.js @@ -0,0 +1,57 @@ +/* eslint-env jest */ +import modeReducer from '../../../src/reducers/mode'; + +const SET_FULL_SCREEN = 'scratch-gui/mode/SET_FULL_SCREEN'; +const SET_PLAYER = 'scratch-gui/mode/SET_PLAYER'; + +test('initialState', () => { + let defaultState; + /* modeReducer(state, action) */ + expect(modeReducer(defaultState, {type: 'anything'})).toBeDefined(); +}); + +test('set full screen mode', () => { + const previousState = { + isAdmin: true, + showBranding: false, + isFullScreen: false, + isPlayerOnly: false, + hasEverEnteredEditor: true + }; + const action = { + type: SET_FULL_SCREEN, + isFullScreen: true + }; + const newState = { + isAdmin: true, + showBranding: false, + isFullScreen: true, + isPlayerOnly: false, + hasEverEnteredEditor: true + }; + /* modeReducer(state, action) */ + expect(modeReducer(previousState, action)).toEqual(newState); +}); + +test('set player mode', () => { + const previousState = { + isAdmin: true, + showBranding: false, + isFullScreen: false, + isPlayerOnly: false, + hasEverEnteredEditor: true + }; + const action = { + type: SET_PLAYER, + isPlayerOnly: true + }; + const newState = { + isAdmin: true, + showBranding: false, + isFullScreen: false, + isPlayerOnly: true, + hasEverEnteredEditor: true + }; + /* modeReducer(state, action) */ + expect(modeReducer(previousState, action)).toEqual(newState); +});