@@ -114,112 +114,112 @@ describe('<CFDPasswordModal/>', () => {
114
114
jest . clearAllMocks ( ) ;
115
115
} ) ;
116
116
117
- // it('should render create Password modal when valid conditions are met', async () => {
118
- // const store = mockStore(mockRootStore);
119
-
120
- // store.client.account_status = { status: ['mt5_password_not_set', 'dxtrade_password_not_set'] };
121
-
122
- // render(
123
- // <Router history={history}>
124
- // <CFDPasswordModal {...mock_props} />
125
- // </Router>,
126
- // {
127
- // wrapper: ({ children }) => <CFDProviders store={store}>{children}</CFDProviders>,
128
- // }
129
- // );
130
- // expect(await screen.findByTestId('dt_create_password')).toBeInTheDocument();
131
- // });
132
-
133
- // it('should render password form with Try later button and forget password button', async () => {
134
- // const store = mockStore(mockRootStore);
135
-
136
- // store.client.account_status = { status: [] };
137
- // store.modules.cfd.error_type = 'PasswordReset';
138
-
139
- // render(
140
- // <Router history={history}>
141
- // <CFDPasswordModal {...mock_props} />
142
- // </Router>,
143
- // {
144
- // wrapper: ({ children }) => <CFDProviders store={store}>{children}</CFDProviders>,
145
- // }
146
- // );
147
-
148
- // expect(await screen.findByRole('button', { name: /try later/i })).toBeInTheDocument();
149
- // expect(await screen.findByRole('button', { name: /forgot password?/i })).toBeInTheDocument();
150
- // });
151
-
152
- // it('should close modal when Forget Password button is clicked', async () => {
153
- // const store = mockStore(mockRootStore);
154
-
155
- // store.client.account_status = { status: ['mt5_password_not_set', 'dxtrade_password_not_set'] };
156
- // store.modules.cfd.error_type = 'PasswordReset';
157
-
158
- // render(
159
- // <Router history={history}>
160
- // <CFDPasswordModal {...mock_props} />
161
- // </Router>,
162
- // {
163
- // wrapper: ({ children }) => <CFDProviders store={store}>{children}</CFDProviders>,
164
- // }
165
- // );
166
- // const ele_forget_btn = await screen.findByRole('button', { name: /forgot password?/i });
167
- // fireEvent.click(ele_forget_btn);
168
-
169
- // await waitFor(() => {
170
- // expect(mockSetCFDSuccessDialog).toHaveBeenCalledWith(false);
171
- // expect(mockDisableCFDPasswordModalFn).toHaveBeenCalled();
172
- // expect(mockSetMt5Error).toHaveBeenCalledWith(false);
173
- // });
174
- // });
175
-
176
- // it('should invoke verifyEmail when forgot password is clicked', async () => {
177
- // const store = mockStore(mockRootStore);
178
-
179
- // store.client.account_status = { status: [], category: 'Real' };
180
- // store.modules.cfd.error_type = 'PasswordReset';
181
- // store.modules.cfd.account_type = { category: 'real', type: 'financial' };
182
-
183
- // render(
184
- // <Router history={history}>
185
- // <CFDPasswordModal {...mock_props} />
186
- // </Router>,
187
- // {
188
- // wrapper: ({ children }) => <CFDProviders store={store}>{children}</CFDProviders>,
189
- // }
190
- // );
191
- // const ele_forget_btn = await screen.findByRole('button', { name: /forgot password?/i });
192
- // fireEvent.click(ele_forget_btn);
193
- // await waitFor(() => {
194
- // expect(WS.verifyEmail).toHaveBeenCalled();
195
- // });
196
- // });
197
-
198
- // it('should display password field for user to enter the password and hold the entered value', async () => {
199
- // const user_input = 'zo8lAet#2q01Ih';
200
-
201
- // const store = mockStore(mockRootStore);
202
-
203
- // store.client.account_status = { status: [], category: 'Real' };
204
-
205
- // render(
206
- // <Router history={history}>
207
- // <CFDPasswordModal {...mock_props} />
208
- // </Router>,
209
- // {
210
- // wrapper: ({ children }) => <CFDProviders store={store}>{children}</CFDProviders>,
211
- // }
212
- // );
213
-
214
- // const ele_password_field = await screen.findByTestId('dt_mt5_password');
215
- // fireEvent.change(ele_password_field, { target: { value: user_input } });
216
-
217
- // expect(await screen.findByRole('button', { name: /add account/i })).toBeInTheDocument();
218
-
219
- // await waitFor(() => {
220
- // expect(ele_password_field.value).toEqual(user_input);
221
- // });
222
- // });
117
+ it ( 'should render create Password modal when valid conditions are met' , async ( ) => {
118
+ const store = mockStore ( mockRootStore ) ;
119
+
120
+ store . client . account_status = { status : [ 'mt5_password_not_set' , 'dxtrade_password_not_set' ] } ;
121
+
122
+ render (
123
+ < Router history = { history } >
124
+ < CFDPasswordModal { ...mock_props } />
125
+ </ Router > ,
126
+ {
127
+ wrapper : ( { children } ) => < CFDProviders store = { store } > { children } </ CFDProviders > ,
128
+ }
129
+ ) ;
130
+ expect ( await screen . findByTestId ( 'dt_create_password' ) ) . toBeInTheDocument ( ) ;
131
+ } ) ;
132
+
133
+ it ( 'should render password form with Try later button and forget password button' , async ( ) => {
134
+ const store = mockStore ( mockRootStore ) ;
135
+
136
+ store . client . account_status = { status : [ ] } ;
137
+ store . modules . cfd . error_type = 'PasswordReset' ;
138
+
139
+ render (
140
+ < Router history = { history } >
141
+ < CFDPasswordModal { ...mock_props } />
142
+ </ Router > ,
143
+ {
144
+ wrapper : ( { children } ) => < CFDProviders store = { store } > { children } </ CFDProviders > ,
145
+ }
146
+ ) ;
147
+
148
+ expect ( await screen . findByRole ( 'button' , { name : / t r y l a t e r / i } ) ) . toBeInTheDocument ( ) ;
149
+ expect ( await screen . findByRole ( 'button' , { name : / f o r g o t p a s s w o r d ? / i } ) ) . toBeInTheDocument ( ) ;
150
+ } ) ;
151
+
152
+ it ( 'should close modal when Forget Password button is clicked' , async ( ) => {
153
+ const store = mockStore ( mockRootStore ) ;
154
+
155
+ store . client . account_status = { status : [ 'mt5_password_not_set' , 'dxtrade_password_not_set' ] } ;
156
+ store . modules . cfd . error_type = 'PasswordReset' ;
157
+
158
+ render (
159
+ < Router history = { history } >
160
+ < CFDPasswordModal { ...mock_props } />
161
+ </ Router > ,
162
+ {
163
+ wrapper : ( { children } ) => < CFDProviders store = { store } > { children } </ CFDProviders > ,
164
+ }
165
+ ) ;
166
+ const ele_forget_btn = await screen . findByRole ( 'button' , { name : / f o r g o t p a s s w o r d ? / i } ) ;
167
+ fireEvent . click ( ele_forget_btn ) ;
168
+
169
+ await waitFor ( ( ) => {
170
+ expect ( mockSetCFDSuccessDialog ) . toHaveBeenCalledWith ( false ) ;
171
+ expect ( mockDisableCFDPasswordModalFn ) . toHaveBeenCalled ( ) ;
172
+ expect ( mockSetMt5Error ) . toHaveBeenCalledWith ( false ) ;
173
+ } ) ;
174
+ } ) ;
175
+
176
+ it ( 'should invoke verifyEmail when forgot password is clicked' , async ( ) => {
177
+ const store = mockStore ( mockRootStore ) ;
178
+
179
+ store . client . account_status = { status : [ ] , category : 'Real' } ;
180
+ store . modules . cfd . error_type = 'PasswordReset' ;
181
+ store . modules . cfd . account_type = { category : 'real' , type : 'financial' } ;
182
+
183
+ render (
184
+ < Router history = { history } >
185
+ < CFDPasswordModal { ...mock_props } />
186
+ </ Router > ,
187
+ {
188
+ wrapper : ( { children } ) => < CFDProviders store = { store } > { children } </ CFDProviders > ,
189
+ }
190
+ ) ;
191
+ const ele_forget_btn = await screen . findByRole ( 'button' , { name : / f o r g o t p a s s w o r d ? / i } ) ;
192
+ fireEvent . click ( ele_forget_btn ) ;
193
+ await waitFor ( ( ) => {
194
+ expect ( WS . verifyEmail ) . toHaveBeenCalled ( ) ;
195
+ } ) ;
196
+ } ) ;
197
+
198
+ it ( 'should display password field for user to enter the password and hold the entered value' , async ( ) => {
199
+ const user_input = 'zo8lAet#2q01Ih' ;
200
+
201
+ const store = mockStore ( mockRootStore ) ;
202
+
203
+ store . client . account_status = { status : [ ] , category : 'Real' } ;
204
+
205
+ render (
206
+ < Router history = { history } >
207
+ < CFDPasswordModal { ...mock_props } />
208
+ </ Router > ,
209
+ {
210
+ wrapper : ( { children } ) => < CFDProviders store = { store } > { children } </ CFDProviders > ,
211
+ }
212
+ ) ;
213
+
214
+ const ele_password_field = await screen . findByTestId ( 'dt_mt5_password' ) ;
215
+ fireEvent . change ( ele_password_field , { target : { value : user_input } } ) ;
216
+
217
+ expect ( await screen . findByRole ( 'button' , { name : / a d d a c c o u n t / i } ) ) . toBeInTheDocument ( ) ;
218
+
219
+ await waitFor ( ( ) => {
220
+ expect ( ele_password_field . value ) . toEqual ( user_input ) ;
221
+ } ) ;
222
+ } ) ;
223
223
224
224
it ( 'should display error message when password does not meet requirements' , async ( ) => {
225
225
validPassword . mockReturnValue ( false ) ;
0 commit comments