Skip to content

Instantly share code, notes, and snippets.

@gyver98
Created March 13, 2017 06:15
Show Gist options
  • Save gyver98/f482176b8c904a9ef1c64becb87b8023 to your computer and use it in GitHub Desktop.
Save gyver98/f482176b8c904a9ef1c64becb87b8023 to your computer and use it in GitHub Desktop.
teslaRangeApp.spec.js
import appReducer from './teslaRangeApp';
const initialState = {
carstats:[
{miles:246, model:"60"},
{miles:250, model:"60D"},
{miles:297, model:"75"},
{miles:306, model:"75D"},
{miles:336, model:"90D"},
{miles:376, model:"P100D"}
],
config: {
speed: 55,
temperature: 20,
climate: true,
wheels: 19
}
}
const climateChangeState = {
carstats:[
{miles:267, model:"60"},
{miles:273, model:"60D"},
{miles:323, model:"75"},
{miles:334, model:"75D"},
{miles:366, model:"90D"},
{miles:409, model:"P100D"}
],
config: {
speed: 55,
temperature: 20,
climate: false,
wheels: 19
}
}
describe('test reducer', () => {
it('should handle initial stat', () => {
expect(
appReducer(undefined, {})
).toEqual(initialState)
})
it('should handle CHANGE_CLIMATE', () => {
expect(
appReducer(initialState,{
type: 'CHANGE_CLIMATE'
})
).toEqual(climateChangeState)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment