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.
Merge pull request #5 from hamid-deriv/hamid/92241/account-platform-d…
…etails-hook Hamid/92241/account platform details hook
- Loading branch information
Showing
7 changed files
with
63 additions
and
25 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
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
35 changes: 35 additions & 0 deletions
35
packages/hooks/src/__tests__/useCurrentAccountDetails.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,35 @@ | ||
import * as React from 'react'; | ||
import { StoreProvider, mockStore } from '@deriv/stores'; | ||
import { renderHook } from '@testing-library/react-hooks'; | ||
import useCurrentAccountDetails from '../useCurrentAccountDetails'; | ||
|
||
describe('useCurrentAccountDetails', () => { | ||
test('should return the account info of the current loginid', async () => { | ||
const mockRootStore = mockStore({ | ||
client: { | ||
account_list: [ | ||
{ | ||
account: { | ||
balance: 10000, | ||
currency: 'USD', | ||
disabled: false, | ||
is_crypto: false, | ||
}, | ||
icon: 'icon', | ||
is_dark_mode_on: false, | ||
loginid: 'loginid', | ||
title: 'title', | ||
}, | ||
], | ||
loginid: 'loginid', | ||
}, | ||
}); | ||
|
||
const wrapper = ({ children }: { children: JSX.Element }) => ( | ||
<StoreProvider store={mockRootStore}>{children}</StoreProvider> | ||
); | ||
const { result } = renderHook(() => useCurrentAccountDetails(), { wrapper }); | ||
|
||
expect(result.current).toStrictEqual(mockRootStore.client.account_list[0]); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,16 +1,17 @@ | ||
export { default as useAccountTransferVisible } from './useAccountTransferVisible'; | ||
export { default as useCountdown } from './useCountdown'; | ||
export { default as useVerifyEmail } from './useVerifyEmail'; | ||
export { default as useNeedAuthentication } from './useNeedAuthentication'; | ||
export { default as useNeedFinancialAssessment } from './useNeedFinancialAssessment'; | ||
export { default as useRealSTPAccount } from './useRealSTPAccount'; | ||
export { default as useNeedTNC } from './useNeedTNC'; | ||
export { default as useCurrentAccountDetails } from './useCurrentAccountDetails'; | ||
export { default as useDepositLocked } from './useDepositLocked'; | ||
export { default as useAccountTransferVisible } from './useAccountTransferVisible'; | ||
export { default as useHasActiveRealAccount } from './useHasActiveRealAccount'; | ||
export { default as useHasMaltaInvestAccount } from './useHasMaltaInvestAccount'; | ||
export { default as useHasSetCurrency } from './useHasSetCurrency'; | ||
export { default as useHasActiveRealAccount } from './useHasActiveRealAccount'; | ||
export { default as useP2PNotificationCount } from './useP2PNotificationCount'; | ||
export { default as useHasSvgAccount } from './useHasSvgAccount'; | ||
export { default as useIsRealAccountNeededForCashier } from './useIsRealAccountNeededForCashier'; | ||
export { default as useNeedAuthentication } from './useNeedAuthentication'; | ||
export { default as useNeedFinancialAssessment } from './useNeedFinancialAssessment'; | ||
export { default as useNeedTNC } from './useNeedTNC'; | ||
export { default as useOnrampVisible } from './useOnrampVisible'; | ||
export { default as useP2PNotificationCount } from './useP2PNotificationCount'; | ||
export { default as useRealSTPAccount } from './useRealSTPAccount'; | ||
export { default as useSwitchToRealAccount } from './useSwitchToRealAccount'; | ||
export { default as useIsRealAccountNeededForCashier } from './useIsRealAccountNeededForCashier'; | ||
export { default as useHasSvgAccount } from './useHasSvgAccount'; | ||
export { default as useVerifyEmail } from './useVerifyEmail'; |
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,10 @@ | ||
import { useStore } from '@deriv/stores'; | ||
|
||
const useCurrentAccountDetails = () => { | ||
const { client } = useStore(); | ||
const { account_list, loginid } = client; | ||
|
||
return account_list.find(account => loginid === account.loginid); | ||
}; | ||
|
||
export default useCurrentAccountDetails; |