Add test for autoRefresh reducer

pull/10616/head
Jared Scheib 2017-03-03 16:57:05 -08:00
parent df5d8e9941
commit 668f4cfdd3
3 changed files with 16 additions and 4 deletions

View File

@ -0,0 +1,12 @@
import {ephemeralReducer, persistedReducer} from 'src/shared/reducers/app'
import {setAutoRefresh} from 'src/shared/actions/app'
describe('Shared.Reducers.app.persisted', () => {
it('should handle SET_AUTOREFRESH', () => {
const initialState = {autoRefresh: 15000}
const milliseconds = 0
const reducedState = persistedReducer(initialState, setAutoRefresh(milliseconds));
expect(reducedState.autoRefresh).to.equal(0);
})
})

View File

@ -1,6 +1,6 @@
import {PRESENTATION_MODE_ANIMATION_DELAY} from '../constants' import {PRESENTATION_MODE_ANIMATION_DELAY} from '../constants'
// ephemeral state reducers // ephemeral state action creators
export const enablePresentationMode = () => ({ export const enablePresentationMode = () => ({
type: 'ENABLE_PRESENTATION_MODE', type: 'ENABLE_PRESENTATION_MODE',
}) })
@ -13,7 +13,7 @@ export const delayEnablePresentationMode = () => (dispatch) => {
setTimeout(() => dispatch(enablePresentationMode()), PRESENTATION_MODE_ANIMATION_DELAY) setTimeout(() => dispatch(enablePresentationMode()), PRESENTATION_MODE_ANIMATION_DELAY)
} }
// persistent state reducers // persistent state action creators
export const setAutoRefresh = (milliseconds) => ({ export const setAutoRefresh = (milliseconds) => ({
type: 'SET_AUTOREFRESH', type: 'SET_AUTOREFRESH',
payload: { payload: {

View File

@ -16,7 +16,7 @@ const {
persisted: initialPersistedState, persisted: initialPersistedState,
} = initialState } = initialState
const ephemeralReducer = (state = initialEphemeralState, action) => { export const ephemeralReducer = (state = initialEphemeralState, action) => {
switch (action.type) { switch (action.type) {
case 'ENABLE_PRESENTATION_MODE': { case 'ENABLE_PRESENTATION_MODE': {
return { return {
@ -37,7 +37,7 @@ const ephemeralReducer = (state = initialEphemeralState, action) => {
} }
} }
const persistedReducer = (state = initialPersistedState, action) => { export const persistedReducer = (state = initialPersistedState, action) => {
switch (action.type) { switch (action.type) {
case 'SET_AUTOREFRESH': { case 'SET_AUTOREFRESH': {
return { return {