Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Unit Test - Login Sagas
describe('Unit Test - Login Sagas', () => {
describe('userLoginSagaRefactor', () => {
describe('when user is authorised', () => {
it('should yield userLoginSagaRefactor saga, which yields getLoginFormState, yield authoriseUser yield LoginActions.clearLogin and yield getUserSettingsSaga', () => {
const generator = userLoginSagaRefactor();
expect(generator.next().value).toEqual(select(getLoginFormState));
expect(
generator.next({
username: 'some username',
password: 'some password',
}).value,
).toEqual(call(authoriseUserSaga, 'some username', 'some password'));
expect(generator.next(true).value).toEqual(
put(LoginActions.clearLogin()),
);
expect(generator.next().value).toEqual(call(getUserSettingsSaga));
expect(generator.next().done).toBeTruthy();
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment