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

Farabi/bot 634/test case for bot stop modal #10112

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from 'react';
import { mockStore, StoreProvider } from '@deriv/stores';
import { render, screen } from '@testing-library/react';
import { mock_ws } from 'Utils/mock';
import RootStore from 'Stores/index';
import { DBotStoreProvider, mockDBotStore } from 'Stores/useDBotStore';
import StopBotModal from '../stop-bot-modal';

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('StopBotModal', () => {
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>
);
});

it('should render the StopBotModal component', () => {
const { container } = render(<StopBotModal />, {
wrapper,
});
expect(container).toBeInTheDocument();
});

it('should render dialog with button label stop my bot', () => {
render(<StopBotModal />, {
wrapper,
});
mock_DBot_store?.quick_strategy?.toggleStopBotDialog();
expect(screen.getByText('Stop my bot')).toBeInTheDocument();
});
});