Start testing reducers

This commit is contained in:
Jordan Eldredge 2017-01-13 21:39:26 -08:00
parent 92bca31b39
commit ea3234fa72
2 changed files with 26 additions and 1 deletions

View file

@ -0,0 +1,25 @@
import {userInput} from '../reducers';
import {
SET_FOCUS,
SET_SCRUB_POSITION,
UNSET_FOCUS
} from '../actionTypes';
describe('userInput reducer', () => {
const state = userInput();
it('has sensible defaults', () => {
expect(state).toEqual({focus: null, scrubPosition: 0});
});
it('can set focus', () => {
const newState = userInput(state, {type: SET_FOCUS, input: 'foo'});
expect(newState).toEqual({focus: 'foo', scrubPosition: 0});
});
it('can unset focus', () => {
const newState = userInput({...state, focus: 'foo'}, {type: UNSET_FOCUS});
expect(newState).toEqual({focus: null, scrubPosition: 0});
});
it('can set scrub position', () => {
const newState = userInput(state, {type: SET_SCRUB_POSITION, position: 5});
expect(newState).toEqual({focus: null, scrubPosition: 5});
});
});

View file

@ -30,7 +30,7 @@ import {
UPDATE_TIME_ELAPSED
} from './actionTypes';
const userInput = (state, action) => {
export const userInput = (state, action) => {
if (!state) {
return {
focus: null,