mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-24 11:01:41 +01:00
35 lines
904 B
JavaScript
35 lines
904 B
JavaScript
import React from 'react';
|
|
import sinon from 'sinon';
|
|
import { shallow } from 'enzyme';
|
|
import { DropdownMenuItem } from './dropdown';
|
|
|
|
describe('Dropdown', () => {
|
|
let wrapper;
|
|
const onClickSpy = sinon.spy();
|
|
const closeMenuSpy = sinon.spy();
|
|
|
|
beforeEach(() => {
|
|
wrapper = shallow(
|
|
<DropdownMenuItem
|
|
onClick={onClickSpy}
|
|
style={{ test: 'style' }}
|
|
closeMenu={closeMenuSpy}
|
|
/>,
|
|
);
|
|
});
|
|
|
|
it('renders li with dropdown-menu-item class', () => {
|
|
expect(wrapper.find('li.dropdown-menu-item')).toHaveLength(1);
|
|
});
|
|
|
|
it('adds style based on props passed', () => {
|
|
expect(wrapper.prop('style').test).toStrictEqual('style');
|
|
});
|
|
|
|
it('simulates click event and calls onClick and closeMenu', () => {
|
|
wrapper.prop('onClick')();
|
|
expect(onClickSpy.callCount).toStrictEqual(1);
|
|
expect(closeMenuSpy.callCount).toStrictEqual(1);
|
|
});
|
|
});
|