1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-27 12:56:01 +01:00
metamask-extension/ui/components/app/dropdowns/dropdown.test.js

32 lines
881 B
JavaScript
Raw Normal View History

import React from 'react';
import { fireEvent } from '@testing-library/react';
import { renderWithProvider } from '../../../../test/lib/render-helpers';
import { DropdownMenuItem } from './dropdown';
2018-09-24 18:28:04 +02:00
describe('Dropdown', () => {
const props = {
onClick: jest.fn(),
closeMenu: jest.fn(),
style: { test: 'style' },
};
2018-09-24 18:28:04 +02:00
it('should matchsnapshot', () => {
const { container } = renderWithProvider(<DropdownMenuItem {...props} />);
2018-09-24 18:28:04 +02:00
expect(container).toMatchSnapshot();
});
2018-09-24 18:28:04 +02:00
it('simulates click event and calls onClick and closeMenu', () => {
const { queryByTestId } = renderWithProvider(
<DropdownMenuItem {...props} />,
);
const dropdownItem = queryByTestId('dropdown-menu-item');
fireEvent.click(dropdownItem);
expect(props.onClick).toHaveBeenCalledTimes(1);
expect(props.closeMenu).toHaveBeenCalledTimes(1);
});
});