Created
November 30, 2021 13:33
-
-
Save Sidnioulz/ef693ea43dd63a6d172342496a78e7ad to your computer and use it in GitHub Desktop.
Sample saga test
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
describe('loginSaga', () => { | |
it('logs a user in when the email and password are recognised', async () => { | |
const { store, dispatched } = configureStore() | |
/* Arrange */ | |
const expirationDate = getFutureDate({ minute: 15 }) | |
mockAxiosSuccess({ expirationDate }) // /auth/login | |
mockAxiosSuccess(annieErnaux) // /auth/fetchCurrentUser | |
/* Act */ | |
store.dispatch(login({ ...goodData })) | |
/* Assert */ | |
await expectAction(dispatched, { type: LOGIN_SUCCESS }) | |
expect(store.getState()).toMatchObject({ | |
auth: { | |
error: null, | |
expirationDate, | |
loginPending: false, | |
user: annieErnaux, | |
}, | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment