mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-02 06:07:06 +01:00
46 lines
1.4 KiB
JavaScript
46 lines
1.4 KiB
JavaScript
|
import React from 'react';
|
||
|
import { render, fireEvent } from '@testing-library/react';
|
||
|
import { Icon, IconName, IconSize } from '../../component-library';
|
||
|
import { ActivityListItem } from './activity-list-item';
|
||
|
|
||
|
const TITLE = 'Hello World';
|
||
|
const SUBTITLE = <p>I am a list item</p>;
|
||
|
const CLASSNAME = 'list-item-test';
|
||
|
const RIGHT_CONTENT = <p>Content rendered to the right</p>;
|
||
|
const CHILDREN = <button>I am a button</button>;
|
||
|
const MID_CONTENT = <p>Content rendered in the middle</p>;
|
||
|
const TOP_CONTENT = <p>Content rendered at the top</p>;
|
||
|
|
||
|
describe('ActivityListItem', () => {
|
||
|
const defaultProps = {
|
||
|
className: CLASSNAME,
|
||
|
title: TITLE,
|
||
|
'data-testid': 'test-id',
|
||
|
subtitle: SUBTITLE,
|
||
|
rightContent: RIGHT_CONTENT,
|
||
|
midContent: MID_CONTENT,
|
||
|
topContent: TOP_CONTENT,
|
||
|
icon: <Icon name={IconName.Custody} size={IconSize.Xs} />,
|
||
|
onClick: jest.fn(),
|
||
|
};
|
||
|
|
||
|
it('should match snapshot with no props', () => {
|
||
|
const { container } = render(<ActivityListItem />);
|
||
|
expect(container).toMatchSnapshot();
|
||
|
});
|
||
|
|
||
|
it('should match snapshot with props', () => {
|
||
|
const { container } = render(
|
||
|
<ActivityListItem {...defaultProps}>{CHILDREN}</ActivityListItem>,
|
||
|
);
|
||
|
|
||
|
expect(container).toMatchSnapshot();
|
||
|
});
|
||
|
|
||
|
it('calls onClick when clicked', () => {
|
||
|
const { getByTestId } = render(<ActivityListItem {...defaultProps} />);
|
||
|
fireEvent.click(getByTestId('test-id'));
|
||
|
expect(defaultProps.onClick).toHaveBeenCalled();
|
||
|
});
|
||
|
});
|