-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Change MPCLogin name and use madProps, adjust tests
- Loading branch information
1 parent
186a3d4
commit 6db406c
Showing
11 changed files
with
165 additions
and
174 deletions.
There are no files selected for viewing
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
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
48 changes: 48 additions & 0 deletions
48
src/components/common/SocialSigner/__tests__/PasswordRecovery.test.tsx
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { fireEvent, render } from '@/tests/test-utils' | ||
import { PasswordRecovery } from '@/components/common/SocialSigner/PasswordRecovery' | ||
import { act, waitFor } from '@testing-library/react' | ||
|
||
describe('PasswordRecovery', () => { | ||
it('displays an error if password is wrong', async () => { | ||
const mockRecoverWithPassword = jest.fn(() => Promise.reject()) | ||
const mockOnSuccess = jest.fn() | ||
|
||
const { getByText, getByLabelText } = render( | ||
<PasswordRecovery recoverFactorWithPassword={mockRecoverWithPassword} onSuccess={mockOnSuccess} />, | ||
) | ||
|
||
const passwordField = getByLabelText('Recovery password') | ||
const submitButton = getByText('Submit') | ||
|
||
act(() => { | ||
fireEvent.change(passwordField, { target: { value: 'somethingwrong' } }) | ||
submitButton.click() | ||
}) | ||
|
||
await waitFor(() => { | ||
expect(mockOnSuccess).not.toHaveBeenCalled() | ||
expect(getByText('Incorrect password')).toBeInTheDocument() | ||
}) | ||
}) | ||
|
||
it('calls onSuccess if password is correct', async () => { | ||
const mockRecoverWithPassword = jest.fn(() => Promise.resolve()) | ||
const mockOnSuccess = jest.fn() | ||
|
||
const { getByText, getByLabelText } = render( | ||
<PasswordRecovery recoverFactorWithPassword={mockRecoverWithPassword} onSuccess={mockOnSuccess} />, | ||
) | ||
|
||
const passwordField = getByLabelText('Recovery password') | ||
const submitButton = getByText('Submit') | ||
|
||
act(() => { | ||
fireEvent.change(passwordField, { target: { value: 'somethingCorrect' } }) | ||
submitButton.click() | ||
}) | ||
|
||
await waitFor(() => { | ||
expect(mockOnSuccess).toHaveBeenCalled() | ||
}) | ||
}) | ||
}) |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.profileImg { | ||
border-radius: var(--space-2); | ||
width: 32px; | ||
height: 32px; | ||
} | ||
|
||
.profileData { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
} | ||
|
||
.loginError { | ||
width: 100%; | ||
margin: 0; | ||
} |
Oops, something went wrong.