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 branch 'develop' into farzin/79040/replace_connect_method_with_…
…useStore_hook_for_cashierlocked_component
- Loading branch information
Showing
100 changed files
with
2,127 additions
and
2,625 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module '@binary-com/binary-document-uploader'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export type TFormValidation = { | ||
warnings: { [key: string]: string }; | ||
errors: { [key: string]: string }; | ||
}; | ||
|
||
export type TToken = { | ||
display_name: string; | ||
last_used: string; | ||
scopes: string[]; | ||
token: string; | ||
}; |
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,18 @@ | ||
import { TToken } from './common-prop.type'; | ||
|
||
export type TPlatformContext = { | ||
is_appstore: boolean; | ||
displayName: string; | ||
}; | ||
|
||
export type TApiContext = { | ||
api_tokens: NonNullable<TToken[]> | undefined; | ||
deleteToken: (token: string) => Promise<void>; | ||
footer_ref: Element | DocumentFragment | undefined; | ||
overlay_ref: | ||
| ((...args: unknown[]) => unknown) | ||
| import('prop-types').InferProps<{ | ||
current: import('prop-types').Requireable<unknown>; | ||
}>; | ||
toggleOverlay: () => void; | ||
}; |
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,2 @@ | ||
export * from './common-prop.type'; | ||
export * from './context.type'; |
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 was deleted.
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
File renamed without changes.
153 changes: 153 additions & 0 deletions
153
packages/cashier/src/hooks/__tests__/useDepositLocked.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,153 @@ | ||
import * as React from 'react'; | ||
// Todo: After upgrading to react 18 we should use @testing-library/react-hooks instead. | ||
import { render, screen } from '@testing-library/react'; | ||
import { StoreProvider } from '../useStore'; | ||
import useDepositLocked from '../useDepositLocked'; | ||
import { TRootStore, DeepPartial } from '../../types'; | ||
|
||
const UseDepositLockedExample = () => { | ||
const is_deposit_locked = useDepositLocked(); | ||
|
||
return ( | ||
<> | ||
<p data-testid={'dt_is_deposit_locked'}>{is_deposit_locked ? 'true' : 'false'}</p> | ||
</> | ||
); | ||
}; | ||
|
||
describe('useDepositLocked', () => { | ||
test('should be false if none of the conditions are met', () => { | ||
const mockRootStore: DeepPartial<TRootStore> = { | ||
client: { | ||
is_deposit_lock: false, | ||
is_authentication_needed: false, | ||
is_tnc_needed: false, | ||
is_eu: false, | ||
is_financial_account: false, | ||
is_financial_information_incomplete: false, | ||
is_trading_experience_incomplete: false, | ||
mt5_login_list: [ | ||
{ | ||
account_type: 'demo', | ||
sub_account_type: 'financial', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
render(<UseDepositLockedExample />, { | ||
wrapper: ({ children }) => <StoreProvider store={mockRootStore}>{children}</StoreProvider>, | ||
}); | ||
|
||
const is_deposit_locked = screen.getByTestId('dt_is_deposit_locked'); | ||
expect(is_deposit_locked).toHaveTextContent('false'); | ||
}); | ||
|
||
test('should be true if is_deposit_lock is true', async () => { | ||
const mockRootStore: DeepPartial<TRootStore> = { | ||
client: { | ||
is_deposit_lock: true, | ||
is_authentication_needed: false, | ||
is_tnc_needed: false, | ||
is_eu: false, | ||
is_financial_account: false, | ||
is_financial_information_incomplete: false, | ||
is_trading_experience_incomplete: false, | ||
mt5_login_list: [ | ||
{ | ||
account_type: 'demo', | ||
sub_account_type: 'financial', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
render(<UseDepositLockedExample />, { | ||
wrapper: ({ children }) => <StoreProvider store={mockRootStore}>{children}</StoreProvider>, | ||
}); | ||
|
||
const is_deposit_locked = screen.getByTestId('dt_is_deposit_locked'); | ||
expect(is_deposit_locked).toHaveTextContent('true'); | ||
}); | ||
|
||
test('should be true if is_need_tnc is true', async () => { | ||
const mockRootStore: DeepPartial<TRootStore> = { | ||
client: { | ||
is_deposit_lock: false, | ||
is_authentication_needed: false, | ||
is_tnc_needed: true, | ||
is_eu: true, | ||
is_financial_account: false, | ||
is_financial_information_incomplete: false, | ||
is_trading_experience_incomplete: false, | ||
mt5_login_list: [ | ||
{ | ||
account_type: 'real', | ||
sub_account_type: 'financial_stp', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
render(<UseDepositLockedExample />, { | ||
wrapper: ({ children }) => <StoreProvider store={mockRootStore}>{children}</StoreProvider>, | ||
}); | ||
|
||
const is_deposit_locked = screen.getByTestId('dt_is_deposit_locked'); | ||
expect(is_deposit_locked).toHaveTextContent('true'); | ||
}); | ||
|
||
test('should be true if is_need_financial_assessment is true', async () => { | ||
const mockRootStore: DeepPartial<TRootStore> = { | ||
client: { | ||
is_deposit_lock: false, | ||
is_authentication_needed: false, | ||
is_tnc_needed: false, | ||
is_eu: false, | ||
is_financial_account: true, | ||
is_financial_information_incomplete: true, | ||
is_trading_experience_incomplete: false, | ||
mt5_login_list: [ | ||
{ | ||
account_type: 'demo', | ||
sub_account_type: 'financial', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
render(<UseDepositLockedExample />, { | ||
wrapper: ({ children }) => <StoreProvider store={mockRootStore}>{children}</StoreProvider>, | ||
}); | ||
|
||
const is_deposit_locked = screen.getByTestId('dt_is_deposit_locked'); | ||
expect(is_deposit_locked).toHaveTextContent('true'); | ||
}); | ||
|
||
test('should be true if is_need_authentication is true', async () => { | ||
const mockRootStore: DeepPartial<TRootStore> = { | ||
client: { | ||
is_deposit_lock: false, | ||
is_authentication_needed: true, | ||
is_tnc_needed: false, | ||
is_eu: true, | ||
is_financial_account: false, | ||
is_financial_information_incomplete: false, | ||
is_trading_experience_incomplete: false, | ||
mt5_login_list: [ | ||
{ | ||
account_type: 'real', | ||
sub_account_type: 'financial_stp', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
render(<UseDepositLockedExample />, { | ||
wrapper: ({ children }) => <StoreProvider store={mockRootStore}>{children}</StoreProvider>, | ||
}); | ||
|
||
const is_deposit_locked = screen.getByTestId('dt_is_deposit_locked'); | ||
expect(is_deposit_locked).toHaveTextContent('true'); | ||
}); | ||
}); |
Oops, something went wrong.