forked from deriv-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.
- Loading branch information
Showing
143 changed files
with
2,771 additions
and
1,251 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
109 changes: 109 additions & 0 deletions
109
packages/account/src/Configs/__test__/personal-details-config.spec.ts
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,109 @@ | ||
import { personal_details_config } from 'Configs/personal-details-config'; | ||
|
||
jest.mock('@deriv/shared', () => ({ | ||
...jest.requireActual('@deriv/shared'), | ||
getErrorMessages: jest.fn().mockReturnValue({ | ||
name: jest.fn(), | ||
password: jest.fn(), | ||
}), | ||
generateValidationFunction: jest.fn(), | ||
getDefaultFields: jest.fn(), | ||
toMoment: jest.fn(), | ||
validLength: jest.fn(), | ||
})); | ||
describe('personal-details-config', () => { | ||
const mock_props = { | ||
residence_list: [ | ||
{ | ||
services: { | ||
idv: { | ||
documents_supported: {}, | ||
has_visual_sample: 0, | ||
is_country_supported: 0, | ||
}, | ||
onfido: { | ||
documents_supported: { | ||
passport: { | ||
display_name: 'Passport', | ||
}, | ||
}, | ||
is_country_supported: 0, | ||
}, | ||
}, | ||
phone_idd: '93', | ||
text: 'Afghanistan', | ||
value: 'af', | ||
tin_format: [], | ||
disabled: '1', | ||
}, | ||
{ | ||
services: { | ||
idv: { | ||
documents_supported: {}, | ||
has_visual_sample: 0, | ||
is_country_supported: 0, | ||
}, | ||
onfido: { | ||
documents_supported: { | ||
driving_licence: { | ||
display_name: 'Driving Licence', | ||
}, | ||
national_identity_card: { | ||
display_name: 'National Identity Card', | ||
}, | ||
passport: { | ||
display_name: 'Passport', | ||
}, | ||
residence_permit: { | ||
display_name: 'Residence Permit', | ||
}, | ||
}, | ||
is_country_supported: 1, | ||
}, | ||
phone_idd: '93', | ||
text: 'Indonesia', | ||
value: 'af', | ||
tin_format: [], | ||
disabled: '1', | ||
}, | ||
}, | ||
], | ||
account_settings: { | ||
tax_residence: 'af', | ||
residence: 'Indonesia', | ||
}, | ||
is_appstore: false, | ||
real_account_signup_target: 'maltainvest', | ||
account_status: { cashier_validation: ['system_maintenance'] }, | ||
}; | ||
|
||
it('should return account tax residence as default value if it is already set', () => { | ||
const personal_details = personal_details_config(mock_props); | ||
expect(personal_details[0].tax_residence.default_value).toEqual('Afghanistan'); | ||
}); | ||
|
||
it('should return residence as the default value for MF clients, If the account tax residence is not set', () => { | ||
const new_props = { | ||
...mock_props, | ||
account_settings: { | ||
...mock_props.account_settings, | ||
tax_residence: '', | ||
}, | ||
}; | ||
const personal_details = personal_details_config(new_props); | ||
expect(personal_details[0].tax_residence.default_value).toEqual(new_props.account_settings.residence); | ||
}); | ||
|
||
it('should not set default value for CR clients, If the account tax residence is not set', () => { | ||
const new_props = { | ||
...mock_props, | ||
real_account_signup_target: 'svg', | ||
account_settings: { | ||
...mock_props.account_settings, | ||
tax_residence: '', | ||
}, | ||
}; | ||
const personal_details = personal_details_config(new_props); | ||
expect(personal_details[0].tax_residence.default_value).toEqual(''); | ||
}); | ||
}); |
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
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
83 changes: 83 additions & 0 deletions
83
...ents/src/components/contract-card/contract-card-items/__tests__/turbos-card-body.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,83 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { TContractInfo } from '@deriv/shared/src/utils/contract/contract-types'; | ||
import TurbosCardBody from '../turbos-card-body'; | ||
|
||
const contract_info: TContractInfo = { | ||
contract_id: 1, | ||
bid_price: 1044.02, | ||
buy_price: 1044.0, | ||
profit: 50, | ||
barrier: '10904.80', | ||
entry_spot_display_value: '1046.80', | ||
sell_price: 1046.8, | ||
}; | ||
|
||
const mockCardLabels = () => ({ | ||
BARRIER: 'Barrier', | ||
CONTRACT_VALUE: 'Contract value', | ||
ENTRY_SPOT: 'Entry spot', | ||
TAKE_PROFIT: 'Take profit', | ||
TOTAL_PROFIT_LOSS: 'Total profit/loss', | ||
PURCHASE_PRICE: 'Buy price', | ||
}); | ||
|
||
describe('TurbosCardBody', () => { | ||
const mock_props = { | ||
addToast: jest.fn(), | ||
connectWithContractUpdate: jest.fn(), | ||
contract_info, | ||
contract_update: { | ||
take_profit: { | ||
display_name: 'Take profit', | ||
order_amount: 0, | ||
order_date: 1678948046, | ||
}, | ||
}, | ||
currency: 'USD', | ||
current_focus: null, | ||
error_message_alignment: 'left', | ||
getCardLabels: mockCardLabels, | ||
getContractById: jest.fn(), | ||
is_sold: false, | ||
onMouseLeave: jest.fn(), | ||
removeToast: jest.fn(), | ||
setCurrentFocus: jest.fn(), | ||
status: 'profit', | ||
progress_slider_mobile_el: false, | ||
}; | ||
beforeAll(() => { | ||
(ReactDOM.createPortal as jest.Mock) = jest.fn(component => { | ||
return component; | ||
}); | ||
}); | ||
|
||
it('renders header and values correctly', () => { | ||
render(<TurbosCardBody {...mock_props} />); | ||
const buy_price_header = screen.getByText(mockCardLabels().PURCHASE_PRICE); | ||
expect(buy_price_header).toBeInTheDocument(); | ||
const buy_price_amount = screen.getByText('1,044.00'); | ||
expect(buy_price_amount).toBeInTheDocument(); | ||
|
||
const entry_spot_header = screen.getByText(mockCardLabels().ENTRY_SPOT); | ||
expect(entry_spot_header).toBeInTheDocument(); | ||
const entry_spot_amount = screen.getByText('1,046.80'); | ||
expect(entry_spot_amount).toBeInTheDocument(); | ||
|
||
const barrier_header = screen.getByText(mockCardLabels().BARRIER); | ||
expect(barrier_header).toBeInTheDocument(); | ||
const barrier_level = screen.getByText('10,904.80'); | ||
expect(barrier_level).toBeInTheDocument(); | ||
|
||
const take_profit_header = screen.getByText(mockCardLabels().TAKE_PROFIT); | ||
expect(take_profit_header).toBeInTheDocument(); | ||
const take_profit_amount = screen.getByText('-'); | ||
expect(take_profit_amount).toBeInTheDocument(); | ||
|
||
const total_profit_loss_header = screen.getByText(mockCardLabels().TOTAL_PROFIT_LOSS); | ||
expect(total_profit_loss_header).toBeInTheDocument(); | ||
const total_profit_loss_amount = screen.getByText('50.00'); | ||
expect(total_profit_loss_amount).toBeInTheDocument(); | ||
}); | ||
}); |
Oops, something went wrong.