mode-reducer.test.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* eslint-env jest */
  2. import modeReducer from '../../../src/reducers/mode';
  3. const SET_FULL_SCREEN = 'scratch-gui/mode/SET_FULL_SCREEN';
  4. const SET_PLAYER = 'scratch-gui/mode/SET_PLAYER';
  5. test('initialState', () => {
  6. let defaultState;
  7. /* modeReducer(state, action) */
  8. expect(modeReducer(defaultState, {type: 'anything'})).toBeDefined();
  9. });
  10. test('set full screen mode', () => {
  11. const previousState = {
  12. showBranding: false,
  13. isFullScreen: false,
  14. isPlayerOnly: false,
  15. hasEverEnteredEditor: true
  16. };
  17. const action = {
  18. type: SET_FULL_SCREEN,
  19. isFullScreen: true
  20. };
  21. const newState = {
  22. showBranding: false,
  23. isFullScreen: true,
  24. isPlayerOnly: false,
  25. hasEverEnteredEditor: true
  26. };
  27. /* modeReducer(state, action) */
  28. expect(modeReducer(previousState, action)).toEqual(newState);
  29. });
  30. test('set player mode', () => {
  31. const previousState = {
  32. showBranding: false,
  33. isFullScreen: false,
  34. isPlayerOnly: false,
  35. hasEverEnteredEditor: true
  36. };
  37. const action = {
  38. type: SET_PLAYER,
  39. isPlayerOnly: true
  40. };
  41. const newState = {
  42. showBranding: false,
  43. isFullScreen: false,
  44. isPlayerOnly: true,
  45. hasEverEnteredEditor: true
  46. };
  47. /* modeReducer(state, action) */
  48. expect(modeReducer(previousState, action)).toEqual(newState);
  49. });