1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-05 15:35:46 +01:00
metamask-extension/ui/components/component-library/avatar-favicon/avatar-favicon.test.js
Nidhi Kumari 9372ce0ec7
added AvatarFavicon component (#16135)
* 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
2022-10-12 16:22:21 -07:00

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',
);
});
});