Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Last active October 20, 2018 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save productioncoder/74c927c4e0c1f2eb2403827e63dbca58 to your computer and use it in GitHub Desktop.
Save productioncoder/74c927c4e0c1f2eb2403827e63dbca58 to your computer and use it in GitHub Desktop.
Youtube test most popular videos reducer
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