Skip to content

Commit

Permalink
Merge pull request #50 from suisin-deriv/suisin/90805/jurisdiction_hi…
Browse files Browse the repository at this point in the history
…gh_level_test_case

Suisin/chore: Test Case for Jurisdiction Modal Checkbox
  • Loading branch information
amina-deriv committed Apr 4, 2023
2 parents 89b73ef + 5e0ea46 commit a4cada9
Showing 1 changed file with 92 additions and 0 deletions.
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();
});
});

0 comments on commit a4cada9

Please sign in to comment.