2022-10-12 20:19:12 +02:00
|
|
|
/* eslint-disable jest/require-top-level-describe */
|
|
|
|
import { render } from '@testing-library/react';
|
|
|
|
import React from 'react';
|
|
|
|
import { AvatarNetwork } from '../avatar-network/avatar-network';
|
|
|
|
import { COLORS } from '../../../helpers/constants/design-system';
|
|
|
|
import { AvatarWithBadge } from './avatar-with-badge';
|
2022-12-21 20:06:40 +01:00
|
|
|
import { AVATAR_WITH_BADGE_POSTIONS } from './avatar-with-badge.constants';
|
2022-10-12 20:19:12 +02:00
|
|
|
|
|
|
|
describe('AvatarWithBadge', () => {
|
|
|
|
it('should render correctly', () => {
|
2022-12-21 20:06:40 +01:00
|
|
|
const { getByTestId, container } = render(
|
2022-10-12 20:19:12 +02:00
|
|
|
<AvatarWithBadge
|
2022-12-21 20:06:40 +01:00
|
|
|
badgePosition={AVATAR_WITH_BADGE_POSTIONS.BOTTOM}
|
2022-10-12 20:19:12 +02:00
|
|
|
data-testid="avatar-with-badge"
|
|
|
|
badge={
|
|
|
|
<AvatarNetwork
|
2022-12-15 18:28:42 +01:00
|
|
|
name="Arbitrum One"
|
|
|
|
src="./images/arbitrum.svg"
|
2022-10-12 20:19:12 +02:00
|
|
|
data-testid="badge"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
/>,
|
|
|
|
);
|
|
|
|
expect(getByTestId('avatar-with-badge')).toBeDefined();
|
|
|
|
expect(getByTestId('badge')).toBeDefined();
|
2022-12-21 20:06:40 +01:00
|
|
|
expect(container).toMatchSnapshot();
|
2022-10-12 20:19:12 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render badge network with bottom right position correctly', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<AvatarWithBadge
|
|
|
|
data-testid="avatar-with-badge"
|
2022-12-21 20:06:40 +01:00
|
|
|
badgePosition={AVATAR_WITH_BADGE_POSTIONS.BOTTOM}
|
2022-10-12 20:19:12 +02:00
|
|
|
badge={
|
|
|
|
<AvatarNetwork
|
2022-12-15 18:28:42 +01:00
|
|
|
name="Arbitrum One"
|
|
|
|
src="./images/arbitrum.svg"
|
2022-10-12 20:19:12 +02:00
|
|
|
data-testid="badge"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
/>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(
|
|
|
|
container.getElementsByClassName(
|
2022-12-21 20:06:40 +01:00
|
|
|
'mm-avatar-with-badge__badge-wrapper--position-bottom',
|
2022-10-12 20:19:12 +02:00
|
|
|
),
|
|
|
|
).toHaveLength(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render badge network with top right position correctly', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<AvatarWithBadge
|
|
|
|
data-testid="avatar-with-badge"
|
2022-12-21 20:06:40 +01:00
|
|
|
badgePosition={AVATAR_WITH_BADGE_POSTIONS.TOP}
|
2022-10-12 20:19:12 +02:00
|
|
|
badge={
|
|
|
|
<AvatarNetwork
|
2022-12-15 18:28:42 +01:00
|
|
|
name="Arbitrum One"
|
|
|
|
src="./images/arbitrum.svg"
|
2022-10-12 20:19:12 +02:00
|
|
|
data-testid="badge"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
/>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(
|
|
|
|
container.getElementsByClassName(
|
2022-12-21 20:06:40 +01:00
|
|
|
'mm-avatar-with-badge__badge-wrapper--position-top',
|
2022-10-12 20:19:12 +02:00
|
|
|
),
|
|
|
|
).toHaveLength(1);
|
|
|
|
});
|
|
|
|
it('should render badge network with badgeWrapperProps', () => {
|
|
|
|
const container = (
|
|
|
|
<AvatarWithBadge
|
|
|
|
data-testid="avatar-with-badge"
|
2022-12-21 20:06:40 +01:00
|
|
|
badgePosition={AVATAR_WITH_BADGE_POSTIONS.TOP}
|
2022-10-12 20:19:12 +02:00
|
|
|
badgeWrapperProps={{ borderColor: COLORS.ERROR_DEFAULT }}
|
|
|
|
badge={
|
|
|
|
<AvatarNetwork
|
2022-12-15 18:28:42 +01:00
|
|
|
name="Arbitrum One"
|
|
|
|
src="./images/arbitrum.svg"
|
2022-10-12 20:19:12 +02:00
|
|
|
data-testid="badge"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
expect(container.props.badgeWrapperProps.borderColor).toStrictEqual(
|
|
|
|
'error-default',
|
|
|
|
);
|
|
|
|
});
|
2022-12-21 20:06:40 +01:00
|
|
|
|
|
|
|
// className
|
|
|
|
it('should render with custom className', () => {
|
|
|
|
const { getByTestId } = render(
|
|
|
|
<AvatarWithBadge
|
|
|
|
data-testid="avatar-with-badge"
|
|
|
|
className="test-class"
|
|
|
|
/>,
|
|
|
|
);
|
|
|
|
expect(getByTestId('avatar-with-badge')).toHaveClass('test-class');
|
|
|
|
});
|
2022-10-12 20:19:12 +02:00
|
|
|
});
|