Skip to content

Instantly share code, notes, and snippets.

@zulucoda
Created January 26, 2019 14:35
Show Gist options
  • Save zulucoda/71dc53500122525b3898fdcfdb540935 to your computer and use it in GitHub Desktop.
Save zulucoda/71dc53500122525b3898fdcfdb540935 to your computer and use it in GitHub Desktop.
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