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.
Akmal | Likhith / feat: vanilla financials (binary-com#8355)
* Akmal / content updates for EU clients (#38) * feat: convert vanilla options component * Revert "Akmal / content updates for EU clients (#38)" * fix: import from shared * likhith / feat: ✨ incorporate vanilla financials * fix: content changes for EU * feat: add unit tests for vanilla options * fix: reuse types * fix: add empty line * fix: remove commented line * chore: refactor test cases * chore: fix datatypes according to latest changes * fix: datatypes warnings * chore: fix formatting * fix: return missing props * feat: update infobox longcode description * feat: remove all payout formatting for vanillas * fix: circle ci warning * fix: execute sell even if bid price is zero * fix: show appropriate error message when trade falls on weekend * chore: make use of useTraderStore hook * feat: trigger vercel * feat: trigger vercel * chore: remove unused logic * feat: content updates for vanilla financial markets * fix: type * fix: circle ci errors after merge * fix: other circle ci issues * feat: improve solution * feat: refactor test cases * feat: small improvements * feat: trigger circle ci * feat: trigger circle ci * fix: code formatting * fix: code formatting * fix: merge conflict * fix: review comments * fix: mobile bug * chore: format code * chore: code suggestions * chore: code suggestions * fix: remove unused variable * fix: data type * fix: resolve issues after merge * fix: circle ci issue * feat: trigger circle ci * feat: modify test cases * chore: remove unused function * feat: refactor vanilla fx logic for contract glossary and description * fix: apply circle ci suggestions * fix: add a key * fix: remove unused variables * feat: add a type * fix: apply review suggestions * fix: new label for trade categories * fix: typescript types * fix: issues after resolving conflicts * fix: test case * feat: refractor the code * fix: circle ci warning * feat: add observer * fix: issues after merge * chore: fix import * fix: refactor logic after conflicts * chore: resolve conflicts
- Loading branch information
1 parent
d99a695
commit 55b29ba
Showing
19 changed files
with
363 additions
and
89 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
...components/contract-card/contract-card-items/__tests__/vanilla-options-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,71 @@ | ||
import React from 'react'; | ||
import { render, RenderResult } from '@testing-library/react'; | ||
import VanillaOptionsCardBody, { TVanillaOptionsCardBodyProps } from '../vanilla-options-card-body'; | ||
|
||
describe('VanillaOptionsCardBody', () => { | ||
const mock_props: TVanillaOptionsCardBodyProps = { | ||
contract_info: { | ||
buy_price: 100, | ||
bid_price: 105, | ||
entry_spot_display_value: '110', | ||
barrier: '120', | ||
sell_price: 95, | ||
profit: -5, | ||
status: 'loss', | ||
}, | ||
currency: 'USD', | ||
getCardLabels: () => ({ | ||
CONTRACT_VALUE: 'Contract Value', | ||
ENTRY_SPOT: 'Entry Spot', | ||
PURCHASE_PRICE: 'Purchase Price', | ||
STRIKE: 'Strike', | ||
TOTAL_PROFIT_LOSS: 'Total Profit/Loss', | ||
}), | ||
is_sold: true, | ||
progress_slider: null, | ||
status: 'loss', | ||
}; | ||
it('should render the correct content for a sold contract', async () => { | ||
// Render the component with the provided props | ||
const { getByText, getByTestId }: RenderResult = render( | ||
<VanillaOptionsCardBody {...mock_props}/> | ||
); | ||
|
||
const indicative_movement = getByTestId('dc-contract-card__indicative--movement'); | ||
|
||
// Test that the correct elements are present in the component | ||
expect(getByText(mock_props.getCardLabels().CONTRACT_VALUE)).toBeInTheDocument(); | ||
expect(getByText(mock_props.getCardLabels().ENTRY_SPOT)).toBeInTheDocument(); | ||
expect(getByText(mock_props.getCardLabels().PURCHASE_PRICE)).toBeInTheDocument(); | ||
expect(getByText(mock_props.getCardLabels().STRIKE)).toBeInTheDocument(); | ||
expect(getByText(mock_props.getCardLabels().TOTAL_PROFIT_LOSS)).toBeInTheDocument(); | ||
expect(indicative_movement).toHaveClass('dc-contract-card__indicative--movement-complete'); | ||
expect(indicative_movement.querySelector('.dc-icon.dc-icon--red')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render the correct content for an unsold contract', async () => { | ||
mock_props.contract_info.profit = 5; | ||
mock_props.contract_info.status = 'profit'; | ||
mock_props.is_sold = false; | ||
mock_props.progress_slider = <div />; | ||
mock_props.status = 'profit'; | ||
delete mock_props.contract_info.sell_price; | ||
|
||
|
||
// Render the component with the provided props | ||
const { getByText, getByTestId }: RenderResult = render( | ||
<VanillaOptionsCardBody {...mock_props}/> | ||
); | ||
|
||
const indicative_movement = getByTestId('dc-contract-card__indicative--movement'); | ||
|
||
// Test that the correct elements are present in the component | ||
expect(getByText(mock_props. getCardLabels().CONTRACT_VALUE)).toBeInTheDocument(); | ||
expect(getByText(mock_props. getCardLabels().ENTRY_SPOT)).toBeInTheDocument(); | ||
expect(getByText(mock_props. getCardLabels().PURCHASE_PRICE)).toBeInTheDocument(); | ||
expect(getByText(mock_props. getCardLabels().STRIKE)).toBeInTheDocument(); | ||
expect(getByText(mock_props. getCardLabels().TOTAL_PROFIT_LOSS)).toBeInTheDocument(); | ||
expect(indicative_movement).not.toHaveClass('dc-contract-card__indicative--movement-complete'); | ||
expect(indicative_movement.querySelector('.dc-icon.dc-icon--green')).toBeInTheDocument(); | ||
}); | ||
}); |
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
Oops, something went wrong.