mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-01 21:57:06 +01:00
f2514c88cf
* added avatar network component * reset showFallback if networkUrl changes * updated changed to avatar network * updated test cases for avatar network * updated story url in README * added avatar network class Name * updated readme for AvatarNetwork * updated avatar network * updated text changes to avatar Network and Avatar Token component * updated space between useState and useEffect * updated scss files in alphabetic order
57 lines
1.7 KiB
JavaScript
57 lines
1.7 KiB
JavaScript
/* eslint-disable jest/require-top-level-describe */
|
|
import { render, screen } from '@testing-library/react';
|
|
import React from 'react';
|
|
|
|
import { AvatarNetwork } from './avatar-network';
|
|
|
|
describe('AvatarNetwork', () => {
|
|
const args = {
|
|
networkName: 'ethereum',
|
|
networkImageUrl: './images/eth_logo.svg',
|
|
showHalo: false,
|
|
};
|
|
|
|
it('should render correctly', () => {
|
|
const { getByTestId } = render(
|
|
<AvatarNetwork data-testid="avatar-network" />,
|
|
);
|
|
expect(getByTestId('avatar-network')).toBeDefined();
|
|
});
|
|
|
|
it('should render image of Avatar Network', () => {
|
|
render(<AvatarNetwork data-testid="avatar-network" {...args} />);
|
|
const image = screen.getByRole('img');
|
|
expect(image).toBeDefined();
|
|
expect(image).toHaveAttribute('src', args.networkImageUrl);
|
|
});
|
|
|
|
it('should render the first letter of the networkName prop if no networkImageUrl is provided', () => {
|
|
const { getByText } = render(
|
|
<AvatarNetwork
|
|
data-testid="avatar-network"
|
|
{...args}
|
|
networkImageUrl=""
|
|
/>,
|
|
);
|
|
expect(getByText('e')).toBeDefined();
|
|
});
|
|
|
|
it('should render halo effect if showHalo is true and image url is there', () => {
|
|
render(<AvatarNetwork data-testid="avatar-network" {...args} showHalo />);
|
|
const image = screen.getAllByRole('img', { hidden: true });
|
|
expect(image[1]).toHaveClass('avatar-network__network-image--size-reduced');
|
|
});
|
|
|
|
it('should render the first letter of the networkName prop when showHalo is true and no image url is provided', () => {
|
|
const { getByText } = render(
|
|
<AvatarNetwork
|
|
{...args}
|
|
networkImageUrl=""
|
|
data-testid="avatar-network"
|
|
showHalo
|
|
/>,
|
|
);
|
|
expect(getByText('e')).toBeDefined();
|
|
});
|
|
});
|