-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: resolved conflicts and updated with master
- Loading branch information
Showing
193 changed files
with
4,056 additions
and
3,472 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
46 changes: 46 additions & 0 deletions
46
packages/account/src/hooks/__test__/useKycAuthStatus.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,46 @@ | ||
import React from 'react'; | ||
import { renderHook } from '@testing-library/react-hooks'; | ||
import { useKycAuthStatus } from '../useKycAuthStatus'; | ||
import { useQuery } from '@deriv/api'; | ||
import { StoreProvider, mockStore } from '@deriv/stores'; | ||
|
||
jest.mock('@deriv/api', () => ({ | ||
...jest.requireActual('@deriv/api'), | ||
useQuery: jest.fn(), | ||
})); | ||
|
||
describe('useKycAuthStatus', () => { | ||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should return kyc_auth_status', () => { | ||
const mock_response = { | ||
data: { | ||
kyc_auth_status: { | ||
identity: { | ||
status: 'none', | ||
}, | ||
document: { | ||
status: 'none', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
const mock = mockStore({ | ||
client: { | ||
is_authorize: true, | ||
}, | ||
}); | ||
|
||
(useQuery as jest.Mock).mockReturnValue(mock_response); | ||
|
||
const wrapper = ({ children }: { children: JSX.Element }) => ( | ||
<StoreProvider store={mock}>{children}</StoreProvider> | ||
); | ||
|
||
const { result } = renderHook(() => useKycAuthStatus({ country: 'in' }), { wrapper }); | ||
expect(result.current.kyc_auth_status).toEqual(mock_response.data.kyc_auth_status); | ||
}); | ||
}); |
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 @@ | ||
export { useKycAuthStatus } from './useKycAuthStatus'; |
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,21 @@ | ||
import { useQuery } from '@deriv/api'; | ||
import { TSocketRequestPayload } from '@deriv/api/types'; | ||
import { useStore } from '@deriv/stores'; | ||
|
||
type TKycAuthStatusPayload = TSocketRequestPayload<'kyc_auth_status'>['payload']; | ||
|
||
/** Custom hook that returns Proof of Identity (POI) and Proof of Address (POA) authentication status details. */ | ||
export const useKycAuthStatus = (payload?: TKycAuthStatusPayload) => { | ||
const { client } = useStore(); | ||
|
||
const { is_authorize } = client; | ||
const { data, ...kyc_auth_status_rest } = useQuery('kyc_auth_status', { | ||
payload, | ||
options: { enabled: is_authorize }, | ||
}); | ||
return { | ||
/** The KYC auth status */ | ||
kyc_auth_status: data?.kyc_auth_status, | ||
...kyc_auth_status_rest, | ||
}; | ||
}; |
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
Oops, something went wrong.