Skip to content

Commit

Permalink
chore: add test case for date-item.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
shafin-deriv committed Oct 6, 2023
1 parent 146af79 commit 700b807
Showing 1 changed file with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React from 'react';
import { mockStore, StoreProvider } from '@deriv/stores';
// eslint-disable-next-line import/no-extraneous-dependencies
import { render, screen } from '@testing-library/react';
import { mock_ws } from 'Utils/mock';
// eslint-disable-next-line import/no-extraneous-dependencies
import RootStore from 'Stores/index';
import { DBotStoreProvider, mockDBotStore } from 'Stores/useDBotStore';
import DateItem from '../date-item';

jest.mock('@deriv/bot-skeleton/src/scratch/blockly', () => jest.fn());
jest.mock('@deriv/bot-skeleton/src/scratch/dbot', () => ({
saveRecentWorkspace: jest.fn(),
unHighlightAllBlocks: jest.fn(),
}));
jest.mock('@deriv/bot-skeleton/src/scratch/hooks/block_svg', () => jest.fn());
jest.mock('@deriv/deriv-charts', () => ({
setSmartChartsPublicPath: jest.fn(),
}));

describe('Draggable', () => {
let wrapper: ({ children }: { children: JSX.Element }) => JSX.Element, mock_DBot_store: RootStore | undefined;

beforeAll(() => {
const mock_store = mockStore({});
mock_DBot_store = mockDBotStore(mock_store, mock_ws);

wrapper = ({ children }: { children: JSX.Element }) => (
<StoreProvider store={mock_store}>
<DBotStoreProvider ws={mock_ws} mock={mock_DBot_store}>
{children}
</DBotStoreProvider>
</StoreProvider>
);
});

test('should renders DateItem', () => {
const { container } = render(<DateItem date='2023-10-06' time='06:39:00 GMT' />, {
wrapper,
});
expect(container).toBeInTheDocument();
});

test('should show date', () => {
render(<DateItem date='2023-10-06' time='06:39:00 GMT' />, {
wrapper,
});
const date_text = screen.getByText('2023-10-06');
expect(date_text).toBeInTheDocument();
});

test('should show time', () => {
render(<DateItem date='2023-10-06' time='06:39:00 GMT' />, {
wrapper,
});
const time_text = screen.getByText('06:39:00 GMT');
expect(time_text).toBeInTheDocument();
});
});

0 comments on commit 700b807

Please sign in to comment.