forked from binary-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WALL] Jim/WALL-4001/ Send email when forgot password is clicked (bin…
…ary-com#15107) * chore: send email when forgot password is clicked * chore: add sendemail call to modal on mobile * chore: rename hook * docs: add tsdoc * chore: add sendemail to dependency array * chore: add error handling logic * chore: add error handling for sent email template * chore: remove unnecessary dependencies
- Loading branch information
Showing
5 changed files
with
184 additions
and
45 deletions.
There are no files selected for viewing
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
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
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
42 changes: 42 additions & 0 deletions
42
packages/wallets/src/hooks/__tests__/useSendPasswordResetEmail.spec.tsx
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,42 @@ | ||
import React, { PropsWithChildren } from 'react'; | ||
import { APIProvider } from '@deriv/api-v2'; | ||
import { renderHook } from '@testing-library/react-hooks'; | ||
import WalletsAuthProvider from '../../AuthProvider'; | ||
import useSendPasswordResetEmail from '../useSendPasswordResetEmail'; | ||
|
||
const mockMutate = jest.fn(); | ||
|
||
jest.mock('@deriv/api-v2', () => ({ | ||
...jest.requireActual('@deriv/api-v2'), | ||
useSettings: jest.fn(() => ({ | ||
data: { | ||
email: 'test@meme.com', | ||
}, | ||
})), | ||
useVerifyEmail: jest.fn(() => ({ | ||
mutate: mockMutate, | ||
})), | ||
})); | ||
|
||
const wrapper = ({ children }: PropsWithChildren) => ( | ||
<APIProvider> | ||
<WalletsAuthProvider>{children}</WalletsAuthProvider> | ||
</APIProvider> | ||
); | ||
|
||
describe('useSendPasswordResetEmail', () => { | ||
it('should call mutate when sendEmail is called', () => { | ||
const { result } = renderHook(() => useSendPasswordResetEmail(), { wrapper }); | ||
result.current.sendEmail({ | ||
isInvestorPassword: true, | ||
platform: 'mt5', | ||
}); | ||
expect(mockMutate).toHaveBeenCalledWith({ | ||
type: 'trading_platform_investor_password_reset', | ||
url_parameters: { | ||
redirect_to: 10, | ||
}, | ||
verify_email: 'test@meme.com', | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.