Skip to content

Commit

Permalink
Amina/test_coverage_for_poi-verified_component_in_account_package (#5006
Browse files Browse the repository at this point in the history
)

* poi-verified-spec

* poi-verified-spec

Co-authored-by: Carol Sachdeva <58209918+carol-binary@users.noreply.github.com>
  • Loading branch information
amina-deriv and carolsachdeva authored Mar 16, 2022
1 parent c86635e commit aa0ee31
Showing 1 changed file with 40 additions and 0 deletions.
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();
});
});

0 comments on commit aa0ee31

Please sign in to comment.