@@ -4,12 +4,18 @@ import { act, render, screen, waitFor } from '@testing-library/react';
4
4
import userEvent from '@testing-library/user-event' ;
5
5
import PoiConfirmWithExampleFormContainer from '../poi-confirm-with-example-form-container' ;
6
6
import { APIProvider } from '@deriv/api' ;
7
+ import { useGetPhoneNumberList } from '@deriv/hooks' ;
7
8
8
9
jest . mock ( '@deriv/quill-icons' , ( ) => ( {
9
10
...jest . requireActual ( '@deriv/quill-icons' ) ,
10
11
DerivLightNameDobPoiIcon : ( ) => 'DerivLightNameDobPoiIcon' ,
11
12
} ) ) ;
12
13
14
+ jest . mock ( '@deriv/hooks' , ( ) => ( {
15
+ ...jest . requireActual ( '@deriv/hooks' ) ,
16
+ useGetPhoneNumberList : jest . fn ( ) ,
17
+ } ) ) ;
18
+
13
19
jest . mock ( '@deriv/shared' , ( ) => ( {
14
20
...jest . requireActual ( '@deriv/shared' ) ,
15
21
isDesktop : jest . fn ( ( ) => true ) ,
@@ -46,6 +52,11 @@ jest.mock('@deriv/shared', () => ({
46
52
describe ( '<PoiConfirmWithExampleFormContainer/>' , ( ) => {
47
53
beforeAll ( ( ) => {
48
54
( ReactDOM . createPortal as jest . Mock ) = jest . fn ( element => element ) ;
55
+ ( useGetPhoneNumberList as jest . Mock ) . mockReturnValue ( {
56
+ legacy_core_countries_list : [
57
+ { text : 'United States (+1)' , value : '+1' , id : '1_US' , carriers : [ ] , disabled : false } ,
58
+ ] ,
59
+ } ) ;
49
60
} ) ;
50
61
afterEach ( ( ) => {
51
62
( ReactDOM . createPortal as jest . Mock ) . mockClear ( ) ;
@@ -71,7 +82,7 @@ describe('<PoiConfirmWithExampleFormContainer/>', () => {
71
82
expect ( await screen . findByText ( 'DerivLightNameDobPoiIcon' ) ) . toBeInTheDocument ( ) ;
72
83
expect ( screen . getByText ( clarification_message ) ) . toBeInTheDocument ( ) ;
73
84
const checkbox_el : HTMLInputElement = screen . getByRole ( 'checkbox' ) ;
74
- expect ( checkbox_el . checked ) . toBeFalsy ( ) ;
85
+ expect ( checkbox_el ) . not . toBeChecked ( ) ;
75
86
76
87
const input_fields : HTMLInputElement [ ] = screen . getAllByRole ( 'textbox' ) ;
77
88
expect ( input_fields ) . toHaveLength ( 3 ) ;
@@ -84,29 +95,29 @@ describe('<PoiConfirmWithExampleFormContainer/>', () => {
84
95
renderComponent ( { } ) ;
85
96
86
97
const checkbox_el : HTMLInputElement = await screen . findByRole ( 'checkbox' ) ;
87
- expect ( checkbox_el . checked ) . toBeFalsy ( ) ;
98
+ expect ( checkbox_el ) . not . toBeChecked ( ) ;
88
99
89
100
const input_fields : HTMLInputElement [ ] = screen . getAllByRole ( 'textbox' ) ;
90
101
const first_name_input = input_fields [ 0 ] ;
91
102
const last_name_input = input_fields [ 1 ] ;
92
103
const dob_input = input_fields [ 2 ] ;
93
104
94
- expect ( first_name_input . value ) . toBe ( 'test first name' ) ;
95
- expect ( last_name_input . value ) . toBe ( 'test last name' ) ;
96
- expect ( dob_input . value ) . toBe ( '2003-08-02' ) ;
105
+ expect ( first_name_input ) . toHaveValue ( 'test first name' ) ;
106
+ expect ( last_name_input ) . toHaveValue ( 'test last name' ) ;
107
+ expect ( dob_input ) . toHaveValue ( '2003-08-02' ) ;
97
108
98
- userEvent . clear ( first_name_input ) ;
99
- userEvent . clear ( last_name_input ) ;
100
- userEvent . type ( first_name_input , 'new test first name' ) ;
101
- userEvent . type ( last_name_input , 'new test last name' ) ;
109
+ await userEvent . clear ( first_name_input ) ;
110
+ await userEvent . clear ( last_name_input ) ;
111
+ await userEvent . type ( first_name_input , 'new test first name' ) ;
112
+ await userEvent . type ( last_name_input , 'new test last name' ) ;
102
113
103
114
await waitFor ( ( ) => {
104
115
expect ( first_name_input . value ) . toBe ( 'new test first name' ) ;
105
116
expect ( last_name_input . value ) . toBe ( 'new test last name' ) ;
106
117
} ) ;
107
118
108
119
const button_el = screen . getByRole ( 'button' ) ;
109
- userEvent . click ( button_el ) ;
120
+ await userEvent . click ( button_el ) ;
110
121
await userEvent . click ( button_el ) ;
111
122
act ( ( ) => {
112
123
jest . advanceTimersByTime ( 500 ) ;
0 commit comments