-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WALL] Farhan/WALL-2911/Unit test for WalletsErrorScreen component (#…
…12217) * chore: ✨unit tests for WalletsErrorScreen component * chore: ✨ clear mocks * refactor: 🧹 change getbytext to getbyrole
- Loading branch information
1 parent
7b17ce1
commit c17ab6c
Showing
3 changed files
with
37 additions
and
4 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
34 changes: 34 additions & 0 deletions
34
packages/wallets/src/components/WalletsErrorScreen/__tests__/WalletsErrorScreen.spec.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,34 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import WalletsErrorScreen from '../WalletsErrorScreen'; | ||
|
||
describe('WalletsErrorScreen', () => { | ||
afterAll(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should show the correct title and icon with default message', () => { | ||
render(<WalletsErrorScreen />); | ||
expect(screen.getByTestId('dt_error_icon')).toBeInTheDocument(); | ||
expect(screen.getByText('Oops, something went wrong!')).toBeInTheDocument(); | ||
expect( | ||
screen.getByText('Sorry an error occurred. Please try accessing our cashier page again.') | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it('should show the message passed as prop', () => { | ||
render(<WalletsErrorScreen message='Error message from props' />); | ||
expect(screen.getByText('Error message from props')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should reload the page when Try again button is clicked', () => { | ||
const reloadMock = jest.fn(); | ||
Object.defineProperty(window, 'location', { | ||
value: { reload: reloadMock }, | ||
writable: true, | ||
}); | ||
render(<WalletsErrorScreen />); | ||
screen.getByRole('button', { name: 'Try again' }).click(); | ||
expect(reloadMock).toHaveBeenCalled(); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
c17ab6c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
deriv-app – ./
deriv-app.vercel.app
deriv-app-git-master.binary.sx
binary.sx
deriv-app.binary.sx