@@ -3,6 +3,7 @@ import { render, screen } from '@testing-library/react';
3
3
import { Button } from '@deriv/components' ;
4
4
import React from 'react' ;
5
5
import { Verified } from '../verified' ;
6
+ import { MemoryRouter } from 'react-router' ;
6
7
7
8
jest . mock ( 'Components/poa/poa-button' , ( ) => jest . fn ( ( ) => < div data-testid = 'poa-button' /> ) ) ;
8
9
@@ -12,12 +13,20 @@ describe('<Verified/>', () => {
12
13
const needs_poa_msg = 'To continue trading, you must also submit a proof of address.' ;
13
14
14
15
it ( 'should render Verified component' , ( ) => {
15
- render ( < Verified /> ) ;
16
+ render (
17
+ < MemoryRouter >
18
+ < Verified />
19
+ </ MemoryRouter >
20
+ ) ;
16
21
expect ( screen . getByText ( message ) ) . toBeInTheDocument ( ) ;
17
22
} ) ;
18
23
19
24
it ( 'should show icon with message if needs_poa is false' , ( ) => {
20
- render ( < Verified /> ) ;
25
+ render (
26
+ < MemoryRouter >
27
+ < Verified />
28
+ </ MemoryRouter >
29
+ ) ;
21
30
22
31
expect ( screen . getByTestId ( 'dt_IcPoaVerified' ) ) . toBeInTheDocument ( ) ;
23
32
expect ( screen . getByText ( message ) ) . toBeInTheDocument ( ) ;
@@ -28,13 +37,21 @@ describe('<Verified/>', () => {
28
37
expect ( screen . getByRole ( 'button' ) ) . toBeInTheDocument ( ) ;
29
38
} ) ;
30
39
31
- it ( 'should not show redirect button if redirect_button is not passed' , ( ) => {
32
- render ( < Verified /> ) ;
33
- expect ( screen . queryByRole ( 'button' ) ) . not . toBeInTheDocument ( ) ;
40
+ it ( 'should show continue trading button if redirect_button is not passed' , ( ) => {
41
+ render (
42
+ < MemoryRouter >
43
+ < Verified />
44
+ </ MemoryRouter >
45
+ ) ;
46
+ expect ( screen . getByText ( 'Continue trading' ) ) . toBeInTheDocument ( ) ;
34
47
} ) ;
35
48
36
49
it ( 'should show poa buttons and the message if needs_poa is true and is_from_external is false ' , ( ) => {
37
- render ( < Verified needs_poa redirect_button = { redirect_button } /> ) ;
50
+ render (
51
+ < MemoryRouter >
52
+ < Verified needs_poa redirect_button = { redirect_button } />
53
+ </ MemoryRouter >
54
+ ) ;
38
55
expect ( screen . getByTestId ( 'poa-button' ) ) . toBeInTheDocument ( ) ;
39
56
expect ( screen . getByText ( needs_poa_msg ) ) . toBeInTheDocument ( ) ;
40
57
} ) ;
0 commit comments