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

35 lines
904 B
JavaScript
Raw Normal View History

import React from 'react';
import sinon from 'sinon';
import { shallow } from 'enzyme';
import { DropdownMenuItem } from './dropdown';
2018-09-24 18:28:04 +02:00
describe('Dropdown', () => {
let wrapper;
const onClickSpy = sinon.spy();
const closeMenuSpy = sinon.spy();
2018-09-24 18:28:04 +02:00
beforeEach(() => {
2018-09-24 18:28:04 +02:00
wrapper = shallow(
<DropdownMenuItem
onClick={onClickSpy}
2019-12-03 21:50:55 +01:00
style={{ test: 'style' }}
closeMenu={closeMenuSpy}
2020-11-03 00:41:28 +01:00
/>,
);
});
2018-09-24 18:28:04 +02:00
it('renders li with dropdown-menu-item class', () => {
expect(wrapper.find('li.dropdown-menu-item')).toHaveLength(1);
});
2018-09-24 18:28:04 +02:00
it('adds style based on props passed', () => {
expect(wrapper.prop('style').test).toStrictEqual('style');
});
2018-09-24 18:28:04 +02:00
it('simulates click event and calls onClick and closeMenu', () => {
wrapper.prop('onClick')();
expect(onClickSpy.callCount).toStrictEqual(1);
expect(closeMenuSpy.callCount).toStrictEqual(1);
});
});