Last active
October 20, 2018 12:48
-
-
Save productioncoder/74c927c4e0c1f2eb2403827e63dbca58 to your computer and use it in GitHub Desktop.
Youtube test most popular videos reducer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import videosReducer from '../videos'; | |
import {MOST_POPULAR } from '../../actions/video'; | |
import {SUCCESS} from '../../actions'; | |
import mostPopularResponse from './responses/MOST_POPULAR_SUCCESS'; | |
import mostPopularSuccessState from './states/MOST_POPULAR_SUCCESS'; | |
const initialState = { | |
byId: {}, | |
mostPopular: {}, | |
}; | |
describe('videos reducer', () => { | |
test('test undefined action type and initial state with videos reducer', () => { | |
const expectedEndState = {...initialState}; | |
expect(videosReducer(undefined, {type: 'some-unused-type'})).toEqual(expectedEndState); | |
}); | |
test('test MOST_POPULAR_SUCCESS action in video reducer', () => { | |
const startState = {...initialState}; | |
const action = { | |
type: MOST_POPULAR[SUCCESS], | |
response: mostPopularResponse, | |
}; | |
const expectedEndState = { | |
...startState, | |
...mostPopularSuccessState | |
}; | |
expect(videosReducer(startState, action)).toEqual(expectedEndState); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment