/* eslint-disable jest/require-top-level-describe */
import { render } from '@testing-library/react';
import React from 'react';
import { SIZES } from '../../../helpers/constants/design-system';
import { ButtonLink } from './button-link';
describe('ButtonLink', () => {
it('should render button element correctly', () => {
const { getByText, getByTestId, container } = render(
Button Link,
);
expect(getByText('Button Link')).toBeDefined();
expect(container.querySelector('button')).toBeDefined();
expect(getByTestId('button-link')).toHaveClass('mm-button');
});
it('should render anchor element correctly', () => {
const { getByTestId, container } = render(
,
);
expect(getByTestId('button-link')).toHaveClass('mm-button');
const anchor = container.getElementsByTagName('a').length;
expect(anchor).toBe(1);
});
it('should render button as block', () => {
const { getByTestId } = render();
expect(getByTestId('block')).toHaveClass(`mm-button--block`);
});
it('should render with added classname', () => {
const { getByTestId } = render(
,
);
expect(getByTestId('classname')).toHaveClass('mm-button--test');
});
it('should render with different size classes', () => {
const { getByTestId } = render(
<>
>,
);
expect(getByTestId(SIZES.SM)).toHaveClass(`mm-button--size-${SIZES.SM}`);
expect(getByTestId(SIZES.MD)).toHaveClass(`mm-button--size-${SIZES.MD}`);
expect(getByTestId(SIZES.LG)).toHaveClass(`mm-button--size-${SIZES.LG}`);
expect(getByTestId(SIZES.AUTO)).toHaveClass(
`mm-button--size-${SIZES.AUTO}`,
);
});
it('should render with different types', () => {
const { getByTestId } = render(
<>
>,
);
expect(getByTestId('danger')).toHaveClass('mm-button-link--type-danger');
});
it('should render with different button states', () => {
const { getByTestId } = render(
<>
>,
);
expect(getByTestId('loading')).toHaveClass(`mm-button--loading`);
expect(getByTestId('disabled')).toHaveClass(`mm-button--disabled`);
});
it('should render with icon', () => {
const { container } = render(
,
);
const icons = container.getElementsByClassName('icon').length;
expect(icons).toBe(1);
});
});