2022-12-08 19:25:19 +01:00
|
|
|
/* eslint-disable jest/require-top-level-describe */
|
|
|
|
import { render } from '@testing-library/react';
|
|
|
|
import React from 'react';
|
|
|
|
|
2023-04-04 18:48:04 +02:00
|
|
|
import { ICON_NAMES } from '../icon/deprecated';
|
2023-02-02 21:15:26 +01:00
|
|
|
import {
|
|
|
|
BackgroundColor,
|
|
|
|
IconColor,
|
|
|
|
} from '../../../helpers/constants/design-system';
|
2022-12-08 19:25:19 +01:00
|
|
|
import { AvatarIcon, AVATAR_ICON_SIZES } from '.';
|
|
|
|
|
|
|
|
describe('AvatarIcon', () => {
|
|
|
|
it('should render correctly', () => {
|
|
|
|
const { getByTestId, container } = render(
|
|
|
|
<AvatarIcon
|
2023-01-24 18:39:46 +01:00
|
|
|
iconName={ICON_NAMES.SWAP_HORIZONTAL}
|
2022-12-08 19:25:19 +01:00
|
|
|
data-testid="avatar-icon"
|
|
|
|
/>,
|
|
|
|
);
|
|
|
|
expect(getByTestId('avatar-icon')).toBeDefined();
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render with different size classes', () => {
|
|
|
|
const { getByTestId } = render(
|
|
|
|
<>
|
|
|
|
<AvatarIcon
|
2023-01-24 18:39:46 +01:00
|
|
|
iconName={ICON_NAMES.SWAP_HORIZONTAL}
|
2022-12-08 19:25:19 +01:00
|
|
|
size={AVATAR_ICON_SIZES.XS}
|
|
|
|
data-testid={AVATAR_ICON_SIZES.XS}
|
|
|
|
/>
|
|
|
|
<AvatarIcon
|
2023-01-24 18:39:46 +01:00
|
|
|
iconName={ICON_NAMES.SWAP_HORIZONTAL}
|
2022-12-08 19:25:19 +01:00
|
|
|
size={AVATAR_ICON_SIZES.SM}
|
|
|
|
data-testid={AVATAR_ICON_SIZES.SM}
|
|
|
|
/>
|
|
|
|
<AvatarIcon
|
2023-01-24 18:39:46 +01:00
|
|
|
iconName={ICON_NAMES.SWAP_HORIZONTAL}
|
2022-12-08 19:25:19 +01:00
|
|
|
size={AVATAR_ICON_SIZES.MD}
|
|
|
|
data-testid={AVATAR_ICON_SIZES.MD}
|
|
|
|
/>
|
|
|
|
<AvatarIcon
|
2023-01-24 18:39:46 +01:00
|
|
|
iconName={ICON_NAMES.SWAP_HORIZONTAL}
|
2022-12-08 19:25:19 +01:00
|
|
|
size={AVATAR_ICON_SIZES.LG}
|
|
|
|
data-testid={AVATAR_ICON_SIZES.LG}
|
|
|
|
/>
|
|
|
|
<AvatarIcon
|
2023-01-24 18:39:46 +01:00
|
|
|
iconName={ICON_NAMES.SWAP_HORIZONTAL}
|
2022-12-08 19:25:19 +01:00
|
|
|
size={AVATAR_ICON_SIZES.XL}
|
|
|
|
data-testid={AVATAR_ICON_SIZES.XL}
|
|
|
|
/>
|
|
|
|
</>,
|
|
|
|
);
|
|
|
|
expect(getByTestId(AVATAR_ICON_SIZES.XS)).toHaveClass(
|
|
|
|
`mm-avatar-base--size-${AVATAR_ICON_SIZES.XS}`,
|
|
|
|
);
|
|
|
|
expect(getByTestId(AVATAR_ICON_SIZES.SM)).toHaveClass(
|
|
|
|
`mm-avatar-base--size-${AVATAR_ICON_SIZES.SM}`,
|
|
|
|
);
|
|
|
|
expect(getByTestId(AVATAR_ICON_SIZES.MD)).toHaveClass(
|
|
|
|
`mm-avatar-base--size-${AVATAR_ICON_SIZES.MD}`,
|
|
|
|
);
|
|
|
|
expect(getByTestId(AVATAR_ICON_SIZES.LG)).toHaveClass(
|
|
|
|
`mm-avatar-base--size-${AVATAR_ICON_SIZES.LG}`,
|
|
|
|
);
|
|
|
|
expect(getByTestId(AVATAR_ICON_SIZES.XL)).toHaveClass(
|
|
|
|
`mm-avatar-base--size-${AVATAR_ICON_SIZES.XL}`,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render with added classname', () => {
|
|
|
|
const { getByTestId } = render(
|
|
|
|
<AvatarIcon
|
2023-01-24 18:39:46 +01:00
|
|
|
iconName={ICON_NAMES.SWAP_HORIZONTAL}
|
2022-12-08 19:25:19 +01:00
|
|
|
className="mm-avatar-icon--test"
|
|
|
|
data-testid="classname"
|
|
|
|
/>,
|
|
|
|
);
|
|
|
|
expect(getByTestId('classname')).toHaveClass('mm-avatar-icon--test');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render with icon', () => {
|
|
|
|
const { getByTestId } = render(
|
|
|
|
<AvatarIcon
|
2023-01-24 18:39:46 +01:00
|
|
|
iconName={ICON_NAMES.SWAP_HORIZONTAL}
|
2022-12-08 19:25:19 +01:00
|
|
|
iconProps={{ 'data-testid': 'avatar-icon' }}
|
|
|
|
/>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(getByTestId('avatar-icon')).toBeDefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render with success color icon and background color', () => {
|
|
|
|
const { getByTestId } = render(
|
|
|
|
<AvatarIcon
|
2023-01-24 18:39:46 +01:00
|
|
|
iconName={ICON_NAMES.SWAP_HORIZONTAL}
|
2023-02-02 21:15:26 +01:00
|
|
|
color={IconColor.successDefault}
|
|
|
|
backgroundColor={BackgroundColor.successMuted}
|
2022-12-08 19:25:19 +01:00
|
|
|
data-testid="success"
|
|
|
|
/>,
|
|
|
|
);
|
|
|
|
|
2023-03-23 21:00:37 +01:00
|
|
|
expect(getByTestId('success')).toHaveClass('box--color-success-default');
|
2022-12-08 19:25:19 +01:00
|
|
|
expect(getByTestId('success')).toHaveClass(
|
|
|
|
'box--background-color-success-muted',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|