This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat/fix: Add comprehensive tests for ResetPasswor
- Loading branch information
1 parent
2b53e71
commit a23ad13
Showing
1 changed file
with
59 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from 'react' | ||
import { render, fireEvent, waitFor } from '@testing-library/react' | ||
import ResetPassword from 'src/pages/reset-password/index.tsx' | ||
import apiManager from 'common/websocket' | ||
|
||
jest.mock('common/websocket', () => ({ | ||
augmentedSend: jest.fn(), | ||
})) | ||
|
||
describe('ResetPassword', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
it('renders the ResetPassword component', () => { | ||
render(<ResetPassword />) | ||
// Add assertions to check if the component is rendered correctly | ||
}) | ||
|
||
it('validates the email input field', () => { | ||
render(<ResetPassword />) | ||
// Simulate user interactions to test input validation | ||
// Add assertions to check if the validation works as expected | ||
}) | ||
|
||
it('submits the form and makes the API call', async () => { | ||
render(<ResetPassword />) | ||
// Simulate user interactions to fill in the form | ||
fireEvent.click(submitButton) | ||
await waitFor(() => { | ||
// Add assertions to check if the API call is made with the correct parameters | ||
// Add assertions to check if the form is reset after successful submission | ||
}) | ||
}) | ||
|
||
it('handles API errors and displays error messages', async () => { | ||
apiManager.augmentedSend.mockRejectedValueOnce({ error: { message: 'API error' } }) | ||
render(<ResetPassword />) | ||
// Simulate user interactions to fill in the form and submit | ||
await waitFor(() => { | ||
// Add assertions to check if the error message is displayed correctly | ||
}) | ||
}) | ||
|
||
it('handles successful API response', async () => { | ||
apiManager.augmentedSend.mockResolvedValueOnce({ success: true }) | ||
render(<ResetPassword />) | ||
// Simulate user interactions to fill in the form and submit | ||
await waitFor(() => { | ||
// Add assertions to check if the success message is displayed correctly | ||
}) | ||
}) | ||
|
||
it('handles button click events', () => { | ||
render(<ResetPassword />) | ||
// Simulate user interactions to click buttons | ||
// Add assertions to check if the corresponding actions are triggered | ||
}) | ||
}) |