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.
Merge pull request #50 from suisin-deriv/suisin/90805/jurisdiction_hi…
…gh_level_test_case Suisin/chore: Test Case for Jurisdiction Modal Checkbox
- Loading branch information
Showing
1 changed file
with
92 additions
and
0 deletions.
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
packages/cfd/src/Containers/jurisdiction-modal/__test__/jurisdiction-modal-checkbox.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,92 @@ | ||
import React from 'react'; | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import JurisdictionModalCheckbox from '../jurisdiction-modal-checkbox'; | ||
import RootStore from 'Stores/index'; | ||
import { Jurisdiction } from '@deriv/shared'; | ||
|
||
describe('JurisdictionModalCheckbox', () => { | ||
const mock_store = { | ||
client: {}, | ||
common: {}, | ||
ui: {}, | ||
}; | ||
const mockRootStore = new RootStore(mock_store); | ||
|
||
const mock_props = { | ||
class_name: '', | ||
is_checked: false, | ||
jurisdiction_selected_shortcode: '', | ||
onCheck: jest.fn(), | ||
context: mockRootStore, | ||
should_restrict_bvi_account_creation: false, | ||
should_restrict_vanuatu_account_creation: false, | ||
}; | ||
|
||
it('should not render JurisdictionModalCheckbox when jurisdiction is not selected', () => { | ||
render(<JurisdictionModalCheckbox {...mock_props} />); | ||
expect(screen.queryByRole('checkbox')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should render labuan account and displays checkbox', () => { | ||
render(<JurisdictionModalCheckbox {...mock_props} jurisdiction_selected_shortcode={Jurisdiction.LABUAN} />); | ||
expect(screen.queryByRole('checkbox')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render function onCheck when checkbox is clicked for labuan account', () => { | ||
render(<JurisdictionModalCheckbox {...mock_props} jurisdiction_selected_shortcode={Jurisdiction.LABUAN} />); | ||
const checkbox = screen.getByRole('checkbox'); | ||
fireEvent.click(checkbox); | ||
expect(mock_props.onCheck).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should render svg account without displaying checkbox', () => { | ||
render(<JurisdictionModalCheckbox {...mock_props} jurisdiction_selected_shortcode={Jurisdiction.SVG} />); | ||
expect(screen.queryByRole('checkbox')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should render bvi account without restriction and displays checkbox', () => { | ||
render(<JurisdictionModalCheckbox {...mock_props} jurisdiction_selected_shortcode={Jurisdiction.BVI} />); | ||
expect(screen.queryByRole('checkbox')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render function onCheck when checkbox is clicked for bvi account without restriction', () => { | ||
render(<JurisdictionModalCheckbox {...mock_props} jurisdiction_selected_shortcode={Jurisdiction.BVI} />); | ||
const checkbox = screen.getByRole('checkbox'); | ||
fireEvent.click(checkbox); | ||
expect(mock_props.onCheck).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should render bvi account with restriction and does not display checkbox', () => { | ||
render( | ||
<JurisdictionModalCheckbox | ||
{...mock_props} | ||
jurisdiction_selected_shortcode={Jurisdiction.BVI} | ||
should_restrict_bvi_account_creation | ||
/> | ||
); | ||
expect(screen.queryByRole('checkbox')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should render vanuatu account without restriction and displays checkbox', () => { | ||
render(<JurisdictionModalCheckbox {...mock_props} jurisdiction_selected_shortcode={Jurisdiction.VANUATU} />); | ||
expect(screen.queryByRole('checkbox')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render function onCheck when checkbox is clicked for vanuatu account without restriction', () => { | ||
render(<JurisdictionModalCheckbox {...mock_props} jurisdiction_selected_shortcode={Jurisdiction.VANUATU} />); | ||
const checkbox = screen.getByRole('checkbox'); | ||
fireEvent.click(checkbox); | ||
expect(mock_props.onCheck).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should render vanuatu account with restriction and does not display checkbox', () => { | ||
render( | ||
<JurisdictionModalCheckbox | ||
{...mock_props} | ||
jurisdiction_selected_shortcode={Jurisdiction.VANUATU} | ||
should_restrict_vanuatu_account_creation | ||
/> | ||
); | ||
expect(screen.queryByRole('checkbox')).not.toBeInTheDocument(); | ||
}); | ||
}); |