-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add test case for date-item.tsx
- Loading branch information
1 parent
146af79
commit 700b807
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
packages/bot-web-ui/src/components/journal/journal-components/__tests__/date-item.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,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(); | ||
}); | ||
}); |