-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/wallets_with_traders_hub
- Loading branch information
Showing
72 changed files
with
1,145 additions
and
475 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
18 changes: 18 additions & 0 deletions
18
...Components/poa-address-mismatch-hint-box/__tests__/poa-address-mismatch-hint-box.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,18 @@ | ||
import React from 'react'; | ||
import { render, screen, waitFor } from '@testing-library/react'; | ||
import POAAddressMismatchHintBox from '../poa-address-mismatch-hint-box'; | ||
|
||
describe('<POAAddressMismatchHintBox/>', () => { | ||
const msg = | ||
'It appears that the address in your document doesn’t match the address in your Deriv profile. Please update your personal details now with the correct address.'; | ||
|
||
it('should render POAAddressMismatchHintBox component', async () => { | ||
window.HTMLElement.prototype.scrollIntoView = jest.fn(); | ||
|
||
render(<POAAddressMismatchHintBox />); | ||
await waitFor(() => { | ||
expect(window.HTMLElement.prototype.scrollIntoView).toHaveBeenCalled(); | ||
}); | ||
expect(screen.getByText(msg)).toBeVisible(); | ||
}); | ||
}); |
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
78 changes: 78 additions & 0 deletions
78
...tore/src/components/multi-action-button-group/__test__/multi-action-button-group.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,78 @@ | ||
import React from 'react'; | ||
import { Router } from 'react-router'; | ||
import { screen, render } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import MultiActionButtonGroup from '../multi-action-button-group'; | ||
import { createBrowserHistory } from 'history'; | ||
import { routes } from '@deriv/shared'; | ||
|
||
const mock_props = { | ||
link_to: routes.trader, | ||
onAction: jest.fn(), | ||
is_buttons_disabled: false, | ||
is_real: true, | ||
}; | ||
|
||
type TMockProps = { | ||
link_to: string; | ||
onAction: jest.Mock; | ||
is_buttons_disabled: boolean; | ||
is_real: boolean; | ||
}; | ||
|
||
jest.mock('Components/trade-button', () => { | ||
const TradeButton = ({ link_to, onAction, is_buttons_disabled }: TMockProps) => ( | ||
<a href={link_to}> | ||
<button onClick={onAction} disabled={is_buttons_disabled}> | ||
Open | ||
</button> | ||
</a> | ||
); | ||
return TradeButton; | ||
}); | ||
|
||
describe('Test Cases for Multi Action Button Group:', () => { | ||
it('should display "Open" and "Transfer" button within component', () => { | ||
render(<MultiActionButtonGroup {...mock_props} />); | ||
|
||
expect(screen.getByText('Open')).toBeInTheDocument(); | ||
expect(screen.getByText('Transfer')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should display "Top up" button instead of "Transfer" if it is not real', () => { | ||
render(<MultiActionButtonGroup {...mock_props} is_real={false} />); | ||
|
||
expect(screen.getByText('Open')).toBeInTheDocument(); | ||
expect(screen.getByText('Top up')).toBeInTheDocument(); | ||
expect(screen.queryByText('Transfer')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should disable "Open" button if "is_buttons_disabled" is true', () => { | ||
render(<MultiActionButtonGroup {...mock_props} is_buttons_disabled />); | ||
|
||
const open_btn = screen.getByText('Open'); | ||
expect(open_btn).toBeDisabled(); | ||
}); | ||
|
||
it('should execute function when clicking on "Open"', () => { | ||
render(<MultiActionButtonGroup {...mock_props} />); | ||
|
||
const open_btn = screen.getByText('Open'); | ||
userEvent.click(open_btn); | ||
expect(mock_props.onAction).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should redirect to Trade page after "Open" button is clicked', () => { | ||
const history = createBrowserHistory(); | ||
render( | ||
<Router history={history}> | ||
<MultiActionButtonGroup {...mock_props} is_real /> | ||
</Router> | ||
); | ||
|
||
const open_btn = screen.getByText('Open'); | ||
userEvent.click(open_btn); | ||
|
||
expect(history.location.pathname).toBe(routes.trade); | ||
}); | ||
}); |
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.