-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Amina/test_coverage_for_poi-verified_component_in_account_package (#5006
) * poi-verified-spec * poi-verified-spec Co-authored-by: Carol Sachdeva <58209918+carol-binary@users.noreply.github.com>
- Loading branch information
1 parent
c86635e
commit aa0ee31
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
packages/account/src/Components/poi-verified/__tests__/verified.spec.js
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,40 @@ | ||
import React from 'react'; | ||
import { screen, render } from '@testing-library/react'; | ||
import { Button } from '@deriv/components'; | ||
import { Verified } from '../verified'; | ||
|
||
jest.mock('Components/poa-button', () => () => <div data-testid='poa-button' />); | ||
|
||
describe('<Verified/>', () => { | ||
const message = 'Your proof of identity is verified'; | ||
const redirect_button = <Button>Lorem epsom</Button>; | ||
const needs_poa_msg = 'To continue trading, you must also submit a proof of address.'; | ||
|
||
it('should render Verified component', () => { | ||
render(<Verified />); | ||
expect(screen.getByText(message)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should show icon with message if needs_poa is false', () => { | ||
const { container } = render(<Verified />); | ||
expect(container.getElementsByClassName('dc-icon').length).toBe(1); | ||
expect(screen.getByText(message)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should show redirect button if needs_poa and is_from_external are false and have redirect_button', () => { | ||
render(<Verified redirect_button={redirect_button} />); | ||
expect(screen.getByRole('button')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should not show redirect button if redirect_button is not passed', () => { | ||
render(<Verified />); | ||
expect(screen.queryByRole('button')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should show poa buttons and the message if needs_poa is true and is_from_external is false ', () => { | ||
render(<Verified needs_poa redirect_button={redirect_button} />); | ||
expect(screen.getByTestId('poa-button')).toBeInTheDocument(); | ||
expect(screen.getByText(needs_poa_msg)).toBeInTheDocument(); | ||
expect(screen.getByRole('button')).toBeInTheDocument(); | ||
}); | ||
}); |