/* eslint-disable jest/require-top-level-describe */
import { render } from '@testing-library/react';
import React from 'react';
import { renderWithUserEvent } from '../../../../test/lib/render-helpers';
import { BannerTip, BannerTipLogoType } from '.';
describe('BannerTip', () => {
it('should render BannerTip element correctly', () => {
const { getByTestId, container } = render(
should render BannerTip element correctly
,
);
expect(getByTestId('bannerTip')).toHaveClass('mm-banner-tip');
expect(container).toMatchSnapshot();
});
it('should render with different logo types', () => {
const { getByTestId } = render(
<>
should render BannerTip element correctly
should render BannerTip element correctly
>,
);
const imageElement = getByTestId('banner-tip-greeting');
expect(imageElement.tagName).toBe('IMG');
expect(getByTestId('banner-tip-greeting')).toHaveClass(
'mm-banner-tip--logo',
);
expect(getByTestId('banner-tip-chat')).toHaveClass('mm-banner-tip--logo');
});
it('should render with added classname', () => {
const { getByTestId } = render(
should render BannerTip element correctly
,
);
expect(getByTestId('bannerTip')).toHaveClass('mm-banner-tip--test');
});
it('should render BannerTip title', () => {
const { getByText } = render();
expect(getByText('BannerTip title test')).toHaveClass(
'mm-banner-base__title',
);
});
it('should render BannerTip description', () => {
const { getByText } = render(
,
);
expect(getByText('BannerTip description test')).toBeDefined();
});
it('should render BannerTip action button', () => {
const { getByTestId } = render(
console.log('ButtonLink actionButtonOnClick demo')
}
>
Use actionButtonLabel for action text, actionButtonOnClick for the
onClick handler, and actionButtonProps to pass any ButtonLink prop types
such as iconName
,
);
expect(getByTestId('action')).toHaveClass('mm-banner-base__action');
});
it('should render and fire onClose event', async () => {
const onClose = jest.fn();
const { user, getByTestId } = renderWithUserEvent(
,
);
await user.click(getByTestId('close-button'));
expect(onClose).toHaveBeenCalledTimes(1);
});
});