The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/client/components/UserAutoCompleteMultiple/UserAvatarChip.spec.tsx

29 lines
1.0 KiB

import { composeStories } from '@storybook/react';
import { render, screen } from '@testing-library/react';
import { axe } from 'jest-axe';
import UserAvatarChip from './UserAvatarChip';
import * as stories from './UserAvatarChip.stories';
describe('UserAvatarChip', () => {
const testCases = Object.values(composeStories(stories)).map((Story) => [Story.storyName || 'Story', Story]);
test.each(testCases)(`renders %s without crashing`, async (_storyname, Story) => {
const { baseElement } = render(<Story />);
expect(baseElement).toMatchSnapshot();
});
test.each(testCases)('%s should have no a11y violations', async (_storyname, Story) => {
const { container } = render(<Story />);
const results = await axe(container);
expect(results).toHaveNoViolations();
});
it('should pass extra props to the Chip component', () => {
const handleClick = jest.fn();
render(<UserAvatarChip username='testuser' onClick={handleClick} />);
screen.getByRole('button').click();
expect(handleClick).toHaveBeenCalled();
});
});