Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Last active October 20, 2018 12:26
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/3c693cdc80a27024390755baf069d2cc to your computer and use it in GitHub Desktop.
Save productioncoder/3c693cdc80a27024390755baf069d2cc to your computer and use it in GitHub Desktop.
Youtube API reducer tests
import apiReducer from '../api';
import {YOUTUBE_LIBRARY_LOADED} from '../../actions/api';
const initialState = {
libraryLoaded: false,
};
describe('api reducer', () => {
test('test unused action type with default initial state', () => {
const unusedActionType = 'unused-action-type';
const expectedEndState = {...initialState};
expect(apiReducer(undefined, {type: unusedActionType})).toEqual(expectedEndState);
});
test('test api reducer with YOUTUBE_LIBRARY_LOADED action', () => {
const startState = {...initialState};
const expectedEndState = {
libraryLoaded: true,
};
expect(apiReducer(startState, {type: YOUTUBE_LIBRARY_LOADED})).toEqual(expectedEndState);
});
test('test api reducer for idempotence with YOUTUBE_LIBRARY_LOADED action and library already loaded', () => {
const startState = {
libraryLoaded: true,
};
expect(apiReducer(startState, {type: YOUTUBE_LIBRARY_LOADED})).toEqual(startState);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment