/* eslint-disable jest/require-top-level-describe */
import { render, screen } from '@testing-library/react';
import React from 'react';
import { AvatarFavicon, AVATAR_FAVICON_SIZES } from '.';
describe('AvatarFavicon', () => {
const args = {
src: './images/eth_logo.png',
name: 'test',
};
it('should render correctly', () => {
const { getByTestId, container } = render(
,
);
expect(getByTestId('avatar-favicon')).toBeDefined();
expect(container).toMatchSnapshot();
});
it('should render image of Avatar Favicon', () => {
render();
const image = screen.getByRole('img');
expect(image).toBeDefined();
expect(image).toHaveAttribute('src', args.src);
});
it('should render fallback image if no ImageSource is provided', () => {
const { container } = render(
,
);
expect(container.getElementsByClassName('mm-icon')).toHaveLength(1);
});
it('should render fallback image with custom fallbackIconProps if no ImageSource is provided', () => {
const container = (
);
expect(container.props.fallbackIconProps['data-testid']).toStrictEqual(
'fallback-icon',
);
});
it('should render with different size classes', () => {
const { getByTestId } = render(
<>
>,
);
expect(getByTestId(AVATAR_FAVICON_SIZES.XS)).toHaveClass(
`mm-avatar-base--size-${AVATAR_FAVICON_SIZES.XS}`,
);
expect(getByTestId(AVATAR_FAVICON_SIZES.SM)).toHaveClass(
`mm-avatar-base--size-${AVATAR_FAVICON_SIZES.SM}`,
);
expect(getByTestId(AVATAR_FAVICON_SIZES.MD)).toHaveClass(
`mm-avatar-base--size-${AVATAR_FAVICON_SIZES.MD}`,
);
expect(getByTestId(AVATAR_FAVICON_SIZES.LG)).toHaveClass(
`mm-avatar-base--size-${AVATAR_FAVICON_SIZES.LG}`,
);
expect(getByTestId(AVATAR_FAVICON_SIZES.XL)).toHaveClass(
`mm-avatar-base--size-${AVATAR_FAVICON_SIZES.XL}`,
);
});
it('should render with custom classname', () => {
const { getByTestId } = render(
,
);
expect(getByTestId('classname')).toHaveClass('mm-avatar-favicon--test');
});
});