Skip to content

Commit

Permalink
Kate / WEBREL-51 / Test coverage: ProgressSliderStream in Trader pack…
Browse files Browse the repository at this point in the history
…age (deriv-com#9464)

* feat: add unit tests

* refactor: incapsulated trade providers
  • Loading branch information
kate-deriv authored Aug 15, 2023
1 parent bd70a37 commit 3196e06
Showing 1 changed file with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import { screen, render } from '@testing-library/react';
import { mockStore } from '@deriv/stores';
import TraderProviders from '../../../../trader-providers';
import ProgressSliderStream from '../progress-slider-stream';

jest.mock('@deriv/components', () => ({
...jest.requireActual('@deriv/components'),
ProgressSlider: () => <div>Mocked Progress Slider</div>,
}));

const contract_info = {
contract_type: 'TEST',
date_expiry: 1222222224,
date_start: 1222222222,
tick_count: 2,
tick_stream: [
{ epoch: 1, tick: 1, tick_display_value: '300' },
{ epoch: 2, tick: 2, tick_display_value: '302' },
],
};

describe('<ProgressSliderStream />', () => {
const mockProgressSliderStream = (mocked_store, contract_info = null) => {
return (
<TraderProviders store={mocked_store}>
<ProgressSliderStream contract_info={contract_info} />
</TraderProviders>
);
};

it('should not render <ProgressSliderStream /> if contract_info is falsy', () => {
const mock_root_store = mockStore({});
render(mockProgressSliderStream(mock_root_store));

expect(screen.queryByText('Mocked Progress Slider')).not.toBeInTheDocument();
});
it('should render <ProgressSliderStream /> if contract_info was passed in props', () => {
const mock_root_store = mockStore({});
render(mockProgressSliderStream(mock_root_store, contract_info));

expect(screen.getByText('Mocked Progress Slider')).toBeInTheDocument();
});
});

0 comments on commit 3196e06

Please sign in to comment.