1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-29 23:58:06 +01:00
metamask-extension/test/unit/responsive/components/dropdown-test.js
Erik Marks 76a2a9bb8b
@metamask/eslint config@5.0.0 (#10358)
* @metamask/eslint-config@5.0.0
* Update eslintrc and prettierrc
* yarn lint:fix
2021-02-04 10:15:23 -08:00

45 lines
1.1 KiB
JavaScript

import assert from 'assert';
import React from 'react';
import configureMockStore from 'redux-mock-store';
import { fireEvent } from '@testing-library/react';
import sinon from 'sinon';
import { renderWithProvider } from '../../../lib/render-helpers';
import { Dropdown } from '../../../../ui/app/components/app/dropdowns/components/dropdown';
describe('Dropdown components', function () {
const mockState = {
metamask: {},
};
const props = {
isOpen: true,
zIndex: 11,
onClickOutside: sinon.spy(),
style: {
position: 'absolute',
right: 0,
top: '36px',
},
innerStyle: {},
};
it('invokes click handler when item clicked', function () {
const store = configureMockStore()(mockState);
const onClickSpy = sinon.spy();
const { getByText } = renderWithProvider(
<Dropdown {...props}>
<li onClick={onClickSpy}>Item 1</li>
<li onClick={onClickSpy}>Item 2</li>
</Dropdown>,
store,
);
const item1 = getByText(/Item 1/u);
fireEvent.click(item1);
assert.ok(onClickSpy.calledOnce);
});
});