1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
Nidhi Kumari 119a5a4dc4
added avatar token component (#15466)
* added avatar token component

* added avatar token component story

* added avatar token readme to story

* added avatar token readme to story

* added halo effect

* added test to avatar token component

* fixed alt name

* added test for blur

* added test for aria hidden element

* fixed fallback issue

* updated halo id in README

* added changes to avatar token stories

* updated stories and README in storybook

* fixed indentation in stories

* changed component name structure

* updated css for avatar halo image

* updated README for Avatar Base Component

* added className to avatar Token

* Updates to docs and styles

* fixed tests for Avatar Token

* added color to the props

* fixed table props issue

* updated avatar token Readme

* updated args in avatar token stories

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
2022-08-18 22:00:19 +05:30

51 lines
1.6 KiB
JavaScript

/* eslint-disable jest/require-top-level-describe */
import { render, screen } from '@testing-library/react';
import React from 'react';
import { AvatarToken } from './avatar-token';
describe('AvatarToken', () => {
const args = {
tokenName: 'ast',
tokenImageUrl: './AST.png',
showHalo: false,
};
it('should render correctly', () => {
const { getByTestId } = render(<AvatarToken data-testid="avatar-token" />);
expect(getByTestId('avatar-token')).toBeDefined();
});
it('should render image Avatar', () => {
render(<AvatarToken {...args} data-testid="avatar-token" />);
const image = screen.getByRole('img');
expect(image).toBeDefined();
expect(image).toHaveAttribute('src', args.tokenImageUrl);
});
it('should render the first letter of the tokenName prop if no tokenImageUrl is provided', () => {
const { getByText } = render(
<AvatarToken {...args} data-testid="avatar-token" tokenImageUrl="" />,
);
expect(getByText('a')).toBeDefined();
});
it('should render halo effect if showHalo is true and image url is there', () => {
render(<AvatarToken {...args} data-testid="avatar-token" showHalo />);
const image = screen.getAllByRole('img', { hidden: true });
expect(image[1]).toHaveClass('avatar-token__token-image--size-reduced');
});
it('should render text showHalo is true and no image url is provided', () => {
const { getByText } = render(
<AvatarToken
{...args}
tokenImageUrl=""
data-testid="avatar-token"
showHalo
/>,
);
expect(getByText('a')).toBeDefined();
});
});