Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: test case for BotPreview #9951

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import { mockStore, StoreProvider } from '@deriv/stores';
// eslint-disable-next-line import/no-extraneous-dependencies
import { render } from '@testing-library/react';
import { mock_ws } from 'Utils/mock';
import { DBotStoreProvider, mockDBotStore } from 'Stores/useDBotStore';
import BotPreview from '../bot-preview';

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('BotPreview', () => {
it('should render BotPreview component with ref', () => {
const mock_store = mockStore({});
const mock_DBot_store = mockDBotStore(mock_store, mock_ws);
const ref = React.createRef<HTMLDivElement>();

render(
<StoreProvider store={mock_store}>
<DBotStoreProvider ws={mock_ws} mock={mock_DBot_store}>
<BotPreview id_ref={ref} />
</DBotStoreProvider>
</StoreProvider>
);

expect(ref.current).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import React, { RefObject } from 'react';
import WorkspaceControl from './workspace-control';

type TBotPreview = {
id_ref: HTMLElement | React.ReactNode | null;
id_ref: RefObject<HTMLDivElement>;
};

const BotPreview = ({ id_ref }: TBotPreview) => {
Expand Down