Skip to content

Commit 98d8508

Browse files
committed
Adding fullscreen handling into the playback reducer
1 parent aed0cba commit 98d8508

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

app/reducers/playback.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import { HAS_STOPPED } from '../actions/hasStopped';
55
import { SET_VOLUME } from '../actions/setVolume';
66
import { SET_CURRENT_TIME } from '../actions/setCurrentTime';
77
import { SET_DURATION } from '../actions/setDuration';
8+
import { SET_FULLSCREEN } from '../actions/setFullscreen';
89

910
const initialState = {
1011
isPlaying: false,
1112
hasStopped: true,
1213
volume: 50,
1314
currentTime: 0,
14-
duration: 0
15+
duration: 0,
16+
fullscreen: false
1517
};
1618

1719
function setIsPlayingState(isPlaying) {
@@ -56,6 +58,12 @@ function setDurationState(duration) {
5658
};
5759
}
5860

61+
function setFullscreenState(fullscreen) {
62+
return {
63+
fullscreen: fullscreen
64+
};
65+
}
66+
5967
export function playbackReducer(state = initialState, action) {
6068
switch (action.type) {
6169
case IS_PLAYING :
@@ -68,6 +76,8 @@ export function playbackReducer(state = initialState, action) {
6876
return Object.assign({}, state, setCurrentTimeState(action.currentTime));
6977
case SET_DURATION :
7078
return Object.assign({}, state, setDurationState(action.duration));
79+
case SET_FULLSCREEN :
80+
return Object.assign({}, state, setFullscreenState(action.fullscreen));
7181
default:
7282
return state;
7383
}

test/reducers/playback.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { HAS_STOPPED } from '../../app/actions/hasStopped';
66
import { SET_VOLUME } from '../../app/actions/setVolume';
77
import { SET_CURRENT_TIME } from '../../app/actions/setCurrentTime';
88
import { SET_DURATION } from '../../app/actions/setDuration';
9+
import { SET_FULLSCREEN } from '../../app/actions/setFullscreen';
910
import { playbackReducer } from '../../app/reducers/playback';
1011

1112
describe('playbackState', () => {
@@ -103,4 +104,19 @@ describe('playbackState', () => {
103104
assert.strictEqual(state.duration, 75);
104105
});
105106
});
107+
108+
describe('fullscreen property', () => {
109+
it('defaults to false', () => {
110+
assert.strictEqual(playbackReducer(undefined, '').fullscreen, false);
111+
});
112+
113+
it('sets {fullscreen: true} when action.fullscreen is true', () => {
114+
const state = playbackReducer(undefined, {
115+
type: SET_FULLSCREEN,
116+
fullscreen: true
117+
});
118+
119+
assert.strictEqual(state.fullscreen, true);
120+
});
121+
});
106122
});

0 commit comments

Comments
 (0)