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.
accounts/refactor: ♻️ container section in accounts package (deriv-co…
…m#9832) * refactor: ♻️ initial commit * refactor: 🎨 fixed import file paths * fix: 🧑💻 incorporate sonarcloud review * refactor: ♻️ migrated reset-trading-password component to TSX * refactor: 🎨 resolved build failure * fix: ♻️ incorporated lint errors * fix: 🎨 incorporated review comments * fix: 🐛 resize issue * refactor: 🎨 migrated account component to TSX (#47) * refactor: 🎨 migrated account component to TSX * fix: 🎨 refactored code * refactor: 🎨 migrated account to tsx * fix: 🎨 incorporated review comments * chore: 💚 trigger empty commit * fix: 🧪 failing testcase * fix: 🐛 resolve password modal API failure * fix: 🐛 bug regd disabled Financial Assessment * fix: 🚚 updated paths * Merge branch 'master' into sprint-9/account-package-refactor
- Loading branch information
1 parent
f1822ae
commit c39e179
Showing
30 changed files
with
522 additions
and
288 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
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
75 changes: 75 additions & 0 deletions
75
packages/account/src/Containers/Account/__tests__/account.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,75 @@ | ||
import React from 'react'; | ||
import { MemoryRouter, BrowserRouter } from 'react-router-dom'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { StoreProvider, mockStore } from '@deriv/stores'; | ||
import { routes } from '@deriv/shared'; | ||
import { TRoute } from 'Types'; | ||
import Account from '../account'; | ||
|
||
jest.mock('../../Account/page-overlay-wrapper', () => jest.fn(() => <div>MockPageOverlayWrapper</div>)); | ||
|
||
jest.mock('@deriv/components', () => ({ | ||
...jest.requireActual('@deriv/components'), | ||
Loading: () => <div>MockLoading</div>, | ||
})); | ||
|
||
describe('Account', () => { | ||
const store = mockStore({ | ||
ui: { | ||
is_account_settings_visible: true, | ||
}, | ||
}); | ||
|
||
const route_list: Array<TRoute> = [ | ||
{ | ||
getTitle: () => 'Profile', | ||
icon: 'mockIcon', | ||
subroutes: [ | ||
{ | ||
path: routes.personal_details, | ||
component: () => <div>MockPersonalDetails</div>, | ||
getTitle: () => 'Personal details', | ||
default: true, | ||
}, | ||
{ | ||
path: routes.trading_assessment, | ||
component: () => <div>MockTradeAssessment</div>, | ||
getTitle: () => 'Trade assessment', | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
const mock_props: React.ComponentProps<typeof Account> = { | ||
routes: route_list, | ||
}; | ||
|
||
const mock_route = routes.personal_details; | ||
|
||
const renderComponent = ({ store_config = store, route = mock_route, props = mock_props }) => | ||
render( | ||
<MemoryRouter initialEntries={[route]}> | ||
<StoreProvider store={store_config}> | ||
<BrowserRouter> | ||
<Account {...props} /> | ||
</BrowserRouter> | ||
</StoreProvider> | ||
</MemoryRouter> | ||
); | ||
|
||
it('should render account page', () => { | ||
renderComponent({}); | ||
expect(screen.getByText('MockPageOverlayWrapper')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render loader while the client is still logging in', () => { | ||
const new_store_config = mockStore({ | ||
client: { | ||
is_logging_in: true, | ||
}, | ||
}); | ||
|
||
renderComponent({ store_config: new_store_config }); | ||
expect(screen.getByText('MockLoading')).toBeInTheDocument(); | ||
}); | ||
}); |
22 changes: 22 additions & 0 deletions
22
packages/account/src/Containers/Account/__tests__/tradinghub-logout.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 userEvent from '@testing-library/user-event'; | ||
import TradingHubLogout from '../tradinghub-logout'; | ||
|
||
describe('TradingHubLogout', () => { | ||
const mock_props: React.ComponentProps<typeof TradingHubLogout> = { | ||
handleOnLogout: jest.fn(), | ||
}; | ||
|
||
it('should render logout tab', () => { | ||
render(<TradingHubLogout {...mock_props} />); | ||
expect(screen.getByText('Log out')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should invoke handleOnLogout when logout tab is clicked', () => { | ||
render(<TradingHubLogout {...mock_props} />); | ||
const el_tab = screen.getByTestId('dt_logout_tab'); | ||
userEvent.click(el_tab); | ||
expect(mock_props.handleOnLogout).toBeCalledTimes(1); | ||
}); | ||
}); |
Oops, something went wrong.