mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-05 23:44:56 +01:00
9372ce0ec7
* added AvatarFavicon component * updated AvatarFavicon Readme * updated avatar favicon component * added fallback props to avatar favicon * updated test for avatar favicon * updated avatar favicon component * updated typo
47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
/* eslint-disable jest/require-top-level-describe */
|
|
import { render, screen } from '@testing-library/react';
|
|
import React from 'react';
|
|
|
|
import { AvatarFavicon } from './avatar-favicon';
|
|
|
|
describe('AvatarFavicon', () => {
|
|
const args = {
|
|
imageSource: './images/eth_logo.svg',
|
|
};
|
|
|
|
it('should render correctly', () => {
|
|
const { getByTestId } = render(
|
|
<AvatarFavicon data-testid="avatar-favicon" />,
|
|
);
|
|
expect(getByTestId('avatar-favicon')).toBeDefined();
|
|
});
|
|
|
|
it('should render image of Avatar Favicon', () => {
|
|
render(<AvatarFavicon data-testid="avatar-favicon" {...args} />);
|
|
const image = screen.getByRole('img');
|
|
expect(image).toBeDefined();
|
|
expect(image).toHaveAttribute('src', args.imageSource);
|
|
});
|
|
|
|
it('should render fallback image if no ImageSource is provided', () => {
|
|
const { container } = render(
|
|
<AvatarFavicon data-testid="avatar-favicon" />,
|
|
);
|
|
expect(container.getElementsByClassName('icon')).toHaveLength(1);
|
|
});
|
|
|
|
it('should render fallback image with custom fallbackIconProps if no ImageSource is provided', () => {
|
|
const container = (
|
|
<AvatarFavicon
|
|
data-testid="avatar-favicon"
|
|
fallbackIconProps={{
|
|
'data-testid': 'fallback-icon',
|
|
}}
|
|
/>
|
|
);
|
|
expect(container.props.fallbackIconProps['data-testid']).toStrictEqual(
|
|
'fallback-icon',
|
|
);
|
|
});
|
|
});
|