mirror of
https://github.com/captbaritone/webamp.git
synced 2026-01-24 02:36:00 +00:00
Start testing reducers
This commit is contained in:
parent
92bca31b39
commit
ea3234fa72
2 changed files with 26 additions and 1 deletions
25
js/__tests__/reducers-test.js
Normal file
25
js/__tests__/reducers-test.js
Normal 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});
|
||||
});
|
||||
});
|
||||
|
|
@ -30,7 +30,7 @@ import {
|
|||
UPDATE_TIME_ELAPSED
|
||||
} from './actionTypes';
|
||||
|
||||
const userInput = (state, action) => {
|
||||
export const userInput = (state, action) => {
|
||||
if (!state) {
|
||||
return {
|
||||
focus: null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue