Skip to content

Commit

Permalink
test: ChartSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
maryia-deriv committed Jul 1, 2024
1 parent 16178a9 commit 998cd27
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ jest.mock('Assets/SvgComponents/settings/dark/interval-enabled.svg', () =>
describe('<ChartSettings/>', () => {
let default_mock_store: ReturnType<typeof mockStore>;
beforeEach(() => {
default_mock_store = mockStore({});
default_mock_store = mockStore({
contract_trade: {
granularity: 60,
},
});
});

const mockChartSettings = () => {
Expand All @@ -45,4 +49,11 @@ describe('<ChartSettings/>', () => {

expect(default_mock_store.ui.setChartCountdown).toBeCalled();
});
it('should display Unavailable message and disable checkbox if chart granularity === 0 (1 Tick interval)', () => {
default_mock_store.contract_trade.granularity = 0;
render(mockChartSettings());

expect(screen.getByText(/This feature is unavailable for tick intervals/)).toBeInTheDocument();
expect(screen.getByRole('checkbox')).toBeDisabled();
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Checkbox, InlineMessage } from '@deriv/components';
import { localize, Localize } from '@deriv/translations';
import { Localize } from '@deriv/translations';
import MediaItem, { MediaHeading, MediaIcon, MediaDescription } from 'App/Components/Elements/Media';
import { observer, useStore } from '@deriv/stores';

Expand Down Expand Up @@ -50,7 +50,7 @@ const ChartSettings = observer(() => {
id='dt_settings_interval_checkbox'
defaultChecked={is_countdown_visible}
disabled={granularity === 0}
label={localize('Display remaining time for each interval')}
label={<Localize i18n_default_text='Display remaining time for each interval' />}
onChange={e => {
if ('checked' in e.target) {
setCountdown(e.target.checked);
Expand Down

0 comments on commit 998cd27

Please sign in to comment.