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.
Henry/dtra 77/ts migration test coverage accu components (binary-com#…
…8852) * test: ts-migration and test coverage for accumulators chart elements * fix: automate test runners errors * fix: automate test runners errors * test: TS migrated and update test coverage for existing accu components * test: ts-migration and test coverage for existing accumulators components * fix: codecov errors * fix: resolve comments * fix: resolve comments * fix: circle ci error * fix: resolve comments * fix: circleCI errors * fix: CircleCI issues * test: add test for accumulator trade description * fix: remove unnecessary import * fix: remove use of usestore types * fix: remove mockstore and types from typests * fix: circle ci issues * fix: circle ci issues * fix: switch to generics * refactor: cleanup code * fix: change code order * test: ts migration and test coverage of accumulators components * test: add test cases and ts migration of remaining accu components * fix: circleci issue * fix: circlci * fix: circlci * fix: resolve comments * fix: code smells * fix: resolve comments * fix: resolve comments * fix: circlci * fix: code smells * fix: circleci * fix: nit * fix: codecov * fix: switch to userevent * fix: circleCI * fix: circleCI * fix: circleCi * fix: resolve sonarcloud * fix: remove unused imports * fix: circle CI * fix: make a prop optional * fix: circleCI errors * fix: circleCi test * fix: remove extra space * fix: duplicate mock props * fix: circleCI * fix: change file extension
- Loading branch information
1 parent
47b88bd
commit 9b7fc32
Showing
40 changed files
with
526 additions
and
242 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
...src/components/contract-card/contract-card-items/__tests__/accumulator-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,53 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import AccumulatorCardBody from '../accumulator-card-body'; | ||
|
||
type TAccumulatorCardBody = React.ComponentProps<typeof AccumulatorCardBody>; | ||
|
||
describe('<AccumulatorCardBody />', () => { | ||
const mock_props: TAccumulatorCardBody = { | ||
contract_info: { | ||
buy_price: 123, | ||
sell_price: 234, | ||
profit: 111, | ||
contract_id: 12345, | ||
is_valid_to_sell: 1, | ||
status: 'sold', | ||
is_settleable: 1, | ||
is_expired: 1, | ||
}, | ||
contract_update: { | ||
take_profit: { | ||
order_amount: 300, | ||
}, | ||
}, | ||
getCardLabels: () => ({ | ||
CURRENT_STAKE: 'Current stake:', | ||
INITIAL_STAKE: 'Initial stake:', | ||
TAKE_PROFIT: 'Take profit:', | ||
TOTAL_PROFIT_LOSS: 'Total profit/loss:', | ||
}), | ||
is_sold: 1, | ||
status: 'profit', | ||
currency: 'USD', | ||
}; | ||
it('should display all contract card items, label, and values', () => { | ||
render(<AccumulatorCardBody {...mock_props} />); | ||
expect(screen.getByText('Initial stake:')).toBeInTheDocument(); | ||
expect(screen.getByText('123.00')).toBeInTheDocument(); | ||
expect(screen.getByText('Current stake:')).toBeInTheDocument(); | ||
expect(screen.getByText('234.00')).toBeInTheDocument(); | ||
expect(screen.getByText('Total profit/loss:')).toBeInTheDocument(); | ||
expect(screen.getByText('111.00')).toBeInTheDocument(); | ||
expect(screen.getByText('Take profit:')).toBeInTheDocument(); | ||
expect(screen.getByText('300.00')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should display Take profit: label and - as value when take_profit is not available', () => { | ||
if (mock_props?.contract_update?.take_profit?.order_amount) | ||
mock_props.contract_update.take_profit.order_amount = null; | ||
render(<AccumulatorCardBody {...mock_props} />); | ||
expect(screen.getByText('Take profit:')).toBeInTheDocument(); | ||
expect(screen.getByText('-')).toBeInTheDocument(); | ||
}); | ||
}); |
File renamed without changes.
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
22 changes: 22 additions & 0 deletions
22
...ges/trader/src/Assets/Trading/Categories/__tests__/accumulator-trade-description.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,22 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import AccumulatorTradeDescription from '../accumulator-trade-description'; | ||
import userEvent from '@testing-library/user-event'; | ||
|
||
describe('<AccumulatorTradeDescription />', () => { | ||
it('Ensure content of component is rendered properly', () => { | ||
render(<AccumulatorTradeDescription onClick={jest.fn()} />); | ||
expect( | ||
screen.getByText( | ||
/Your stake will continue to grow as long as the current spot price remains within a specified/i | ||
) | ||
).toBeInTheDocument(); | ||
}); | ||
it('Ensure clicking on definition works', () => { | ||
const onClick = jest.fn(); | ||
render(<AccumulatorTradeDescription onClick={onClick} />); | ||
const glossary_definition = screen.getByText(/growth rate/i); | ||
userEvent.click(glossary_definition); | ||
expect(onClick).toHaveBeenCalled(); | ||
}); | ||
}); |
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.