/* 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 { Icon, IconName } from '..';
import { BannerBase } from './banner-base';
describe('BannerBase', () => {
it('should render BannerBase element correctly', () => {
const { getByTestId, container } = render(
should render BannerBase element correctly
,
);
expect(getByTestId('banner-base')).toHaveClass('mm-banner-base');
expect(container).toMatchSnapshot();
});
it('should render with added classname', () => {
const { getByTestId } = render(
should render BannerBase element correctly
,
);
expect(getByTestId('banner-base')).toHaveClass('mm-banner-base--test');
});
it('should render BannerBase title', () => {
const { getByText, getByTestId } = render(
,
);
expect(getByText('BannerBase title test')).toBeDefined();
expect(getByTestId('title')).toBeDefined();
});
it('should render BannerBase description', () => {
const { getByText, getByTestId } = render(
,
);
expect(getByText('BannerBase description test')).toBeDefined();
expect(getByTestId('description')).toBeDefined();
});
it('should render BannerBase children with props', () => {
const { getByText, getByTestId } = render(
BannerBase children
,
);
expect(getByTestId('children-wrapper')).toBeDefined();
expect(getByText('BannerBase children')).toBeDefined();
});
it('should render BannerBase children without wrapper when not a string', () => {
const { getByText, queryByTestId } = render(
BannerBase children
,
);
expect(queryByTestId('children-wrapper')).not.toBeInTheDocument();
expect(getByText('BannerBase children')).toBeDefined();
});
it('should render BannerBase action button', () => {
const fn = jest.fn();
const { getByTestId } = render(
BannerBase children
,
);
expect(getByTestId('action')).toHaveClass('mm-banner-base__action');
});
it('should render BannerBase startAccessory', () => {
const { getByTestId } = render(
}
/>,
);
expect(getByTestId('start-accessory')).toBeDefined();
});
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);
});
});