Skip to content

Instantly share code, notes, and snippets.

@jasongaare
Last active June 28, 2017 14:57
Show Gist options
  • Save jasongaare/5d8f1ac81e70e9321f7e4b8f75ec2ace to your computer and use it in GitHub Desktop.
Save jasongaare/5d8f1ac81e70e9321f7e4b8f75ec2ace to your computer and use it in GitHub Desktop.
import mockStore from 'redux-mock-store';
const store = mockStore();
describe('Testing log in authentication', () => {
beforeEach(() => {
store.clearActions();
});
it('attempt with correct password succeeds', async () => {
await store.dispatch(authenticateUser('email@test.com', 'password'));
expect(store.getActions()).toMatchSnapshot();
});
it('attempt with wrong password fails as expected', async () => {
await store.dispatch(authenticateUser('email@test.com', 'wrong'))
.catch((error) => {
const errorObject = { ...error };
delete errorObject.duration;
expect(errorObject).toMatchSnapshot();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment