Last active
October 20, 2018 12:26
-
-
Save productioncoder/3c693cdc80a27024390755baf069d2cc to your computer and use it in GitHub Desktop.
Youtube API reducer tests
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 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