Skip to content

Instantly share code, notes, and snippets.

@gasserkl
Created September 8, 2021 11:38
Show Gist options
  • Save gasserkl/10566d17e045cbfe6b3aaa6f684660d2 to your computer and use it in GitHub Desktop.
Save gasserkl/10566d17e045cbfe6b3aaa6f684660d2 to your computer and use it in GitHub Desktop.
it("should return the user information after fixing the password", async () => {
// given: The first login attempt was unsucessful
const { result } = renderHook(() => useLogin());
act(() => result.current.onLogin("admin", "incorrect-password"));
await waitFor(() => expect(result.current.isLoginError).toBeTruthy());
await waitFor(() => expect(result.current.loggedInUsername).toBeUndefined());
// when: fixing the password
act(() => result.current.onLogin("admin", "admin"));
// then:
await waitFor(() => expect(result.current.isLoginError).toBeFalsy());
await waitFor(() => expect(result.current.loggedInUsername).toEqual("admin"));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment