import React from 'react';
import { cleanup, fireEvent } from '@testing-library/react';
import { render } from '../../../utils/theme-render-wrapper';
import type { Theme } from '../../@styles/theme-provider';
import { InfoCardWithBars } from './info-card-with-bars';
import type { InfoCardWithBarsProps } from './info-card-with-bars';
import activeSessionMockData from './__mocks__/mockInfoCardWithBars';
declare module '@mui/styles/defaultTheme' {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface DefaultTheme extends Theme {}
}
afterEach(cleanup);
const Wrapper = (props: InfoCardWithBarsProps) => ;
it(`Should render InfoCardWithBars`, () => {
render(
);
});
it(`Should render title tooltip`, () => {
const tooltipText = 'titleTooltipText';
const chartTitle = 'title';
const { findByTestId, getByText } = render(
);
const titleEl = getByText(chartTitle);
fireEvent.mouseEnter(titleEl);
const toolTipElm = findByTestId('titleTooltip');
expect(toolTipElm).toBeTruthy();
fireEvent.mouseLeave(titleEl);
});
it(`Should render button tooltip`, () => {
const tooltipText = 'buttonTooltipText';
const buttonText = 'buttonText';
const { queryByTestId, getByText } = render(
);
const buttonEl = getByText(buttonText);
fireEvent.mouseEnter(buttonEl);
const toolTipElm = queryByTestId('buttonTooltip');
expect(toolTipElm).toBeTruthy();
fireEvent.mouseLeave(buttonEl);
});
it(`Should render button as link`, () => {
const onClick = jest.fn();
const link = '/link/to/somewhere';
const buttonText = 'buttonText';
const { queryByTestId, getByText } = render(
);
const buttonEl = getByText(buttonText);
const linkComponent = queryByTestId('topLinkComponent');
fireEvent.click(buttonEl);
expect(onClick).toBeCalledTimes(1);
expect(linkComponent?.nodeName).toBe('A');
});