Created
January 6, 2016 16:53
-
-
Save jmreidy/0f94aa28a5274abb51cd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* eslint-env node, mocha */ | |
import expect, { createSpy } from 'expect'; | |
import { createStore } from 'redux'; | |
import LoginScreen, { Component as LoginScreenComponent } from '../../src/containers/screens/LoginScreen'; | |
import * as loginActions from '../../src/actions/loginActions'; | |
describe('LoginScreen', () => { | |
//regular component tests | |
}); | |
describe('LoginScreenContainer', () => { | |
const setup = (initialState) => { | |
const renderer = createRenderer(); | |
const store = createStore((state) => state, initialState); | |
expect.spyOn(store, 'dispatch'); | |
renderer.render(<LoginScreen store={store}/>); | |
const output = renderer.getRenderOutput(); | |
return { | |
store, | |
output, | |
renderer, | |
}; | |
}; | |
it('renders the component correctly', () => { | |
const { output } = setup({}); | |
expect(output.type).toBe(LoginScreenComponent); | |
}); | |
it('passes store props correctly', () => { | |
const { output } = setup({ loggedIn: false }); | |
expect(output.props.loggedIn).toEqual(false); | |
}); | |
it('passes action props correctly', () => { | |
expect.spyOn(loginActions, 'login'); | |
const { store, output } = setup({}); | |
const username = 'username'; | |
const password = 'password'; | |
output.props.login(username, password); | |
expect(loginActions.login).toHaveBeenCalledWith(username, password); | |
expect(store.dispatch).toHaveBeenCalledWith(loginActions.login(username, password)); | |
loginActions.login.restore(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where is createRenderer coming from?