From cf7a134fca9847fc3855ff86961330ba8a922743 Mon Sep 17 00:00:00 2001 From: shafin-deriv Date: Thu, 21 Sep 2023 15:37:49 +0800 Subject: [PATCH] chore: test case for recent-footer --- .../__tests__/recent-footer.spec.tsx | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 packages/bot-web-ui/src/components/dashboard/dashboard-component/load-bot-preview/__tests__/recent-footer.spec.tsx diff --git a/packages/bot-web-ui/src/components/dashboard/dashboard-component/load-bot-preview/__tests__/recent-footer.spec.tsx b/packages/bot-web-ui/src/components/dashboard/dashboard-component/load-bot-preview/__tests__/recent-footer.spec.tsx new file mode 100644 index 000000000000..6c27e3939ef6 --- /dev/null +++ b/packages/bot-web-ui/src/components/dashboard/dashboard-component/load-bot-preview/__tests__/recent-footer.spec.tsx @@ -0,0 +1,48 @@ +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'; +import RootStore from 'Stores/root-store'; +import { DBotStoreProvider, mockDBotStore } from 'Stores/useDBotStore'; +import RecentFooter from '../recent-footer'; + +jest.mock('@deriv/shared', () => ({ + ...jest.requireActual('@deriv/shared'), + isMobile: jest.fn(), +})); + +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()); + +describe('RecentFooter', () => { + 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 }) => ( + + + {children} + + + ); + }); + + it('should render RecentFooter', () => { + const { container } = render(, { wrapper }); + expect(container).toBeInTheDocument(); + }); + + it('should render open button', async () => { + render(, { wrapper }); + const open_button = screen.getByText('Open'); + expect(open_button).toBeInTheDocument(); + }); +});