forked from binary-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add test coverage for currency switcher container (binary-com#…
- Loading branch information
1 parent
b457650
commit 08fe6e7
Showing
4 changed files
with
200 additions
and
59 deletions.
There are no files selected for viewing
140 changes: 140 additions & 0 deletions
140
packages/appstore/src/components/containers/__tests__/currency-switcher-container.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,140 @@ | ||
import React from 'react'; | ||
import CurrentSwitcherContainer from '../currency-switcher-container'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { StoreProvider, mockStore } from '@deriv/stores'; | ||
|
||
describe('CurrentSwitcherContainer', () => { | ||
it('should render the modal', async () => { | ||
const mock = mockStore({ | ||
modules: { | ||
cfd: { | ||
current_list: { | ||
CR123123: { | ||
landing_company_short: 'maltainvest', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
const wrapper = ({ children }: { children: JSX.Element }) => ( | ||
<StoreProvider store={mock}>{children}</StoreProvider> | ||
); | ||
|
||
const { container } = render( | ||
<CurrentSwitcherContainer actions={null} has_interaction={false} icon='USD' title='USD' />, | ||
{ | ||
wrapper, | ||
} | ||
); | ||
expect(container).toBeInTheDocument(); | ||
}); | ||
|
||
it('should not have the dropdown if is demo is true', () => { | ||
const mock = mockStore({ | ||
modules: { | ||
cfd: { | ||
current_list: { | ||
CR123123: { | ||
landing_company_short: 'maltainvest', | ||
}, | ||
}, | ||
}, | ||
}, | ||
traders_hub: { | ||
is_demo: true, | ||
}, | ||
}); | ||
const wrapper = ({ children }: { children: JSX.Element }) => ( | ||
<StoreProvider store={mock}>{children}</StoreProvider> | ||
); | ||
|
||
render(<CurrentSwitcherContainer actions={null} has_interaction={false} icon='USD' title='USD' />, { | ||
wrapper, | ||
}); | ||
|
||
expect(screen.queryByTestId('currency-switcher-container__arrow')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should not have the dropdown if is_eu_user is true', () => { | ||
const mock = mockStore({ | ||
modules: { | ||
cfd: { | ||
current_list: { | ||
CR123123: { | ||
landing_company_short: 'maltainvest', | ||
}, | ||
}, | ||
}, | ||
}, | ||
traders_hub: { | ||
is_eu_user: true, | ||
}, | ||
}); | ||
const wrapper = ({ children }: { children: JSX.Element }) => ( | ||
<StoreProvider store={mock}>{children}</StoreProvider> | ||
); | ||
|
||
render(<CurrentSwitcherContainer actions={null} has_interaction={false} icon='USD' title='USD' />, { | ||
wrapper, | ||
}); | ||
|
||
expect(screen.queryByTestId('currency-switcher-container__arrow')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should have pending in the classname if the document status is pending', () => { | ||
const mock = mockStore({ | ||
modules: { | ||
cfd: { | ||
current_list: { | ||
CR123123: { | ||
landing_company_short: 'maltainvest', | ||
}, | ||
}, | ||
}, | ||
}, | ||
client: { | ||
authentication_status: { | ||
document_status: 'pending', | ||
}, | ||
}, | ||
}); | ||
const wrapper = ({ children }: { children: JSX.Element }) => ( | ||
<StoreProvider store={mock}>{children}</StoreProvider> | ||
); | ||
|
||
render(<CurrentSwitcherContainer actions={null} has_interaction={false} icon='USD' title='USD' />, { | ||
wrapper, | ||
}); | ||
|
||
expect(screen.getByText('USD')).toHaveClass('currency-switcher-container__content--text--pending'); | ||
}); | ||
|
||
it('should have default in the classname if the document status is default', () => { | ||
const mock = mockStore({ | ||
modules: { | ||
cfd: { | ||
current_list: { | ||
CR123123: { | ||
landing_company_short: 'maltainvest', | ||
}, | ||
}, | ||
}, | ||
}, | ||
client: { | ||
authentication_status: { | ||
document_status: 'default', | ||
}, | ||
}, | ||
}); | ||
const wrapper = ({ children }: { children: JSX.Element }) => ( | ||
<StoreProvider store={mock}>{children}</StoreProvider> | ||
); | ||
|
||
render(<CurrentSwitcherContainer actions={null} has_interaction={false} icon='USD' title='USD' />, { | ||
wrapper, | ||
}); | ||
|
||
expect(screen.getByText('USD')).toHaveClass('currency-switcher-container__content--text--default'); | ||
}); | ||
}); |
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