You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
904 B
35 lines
904 B
4 years ago
|
import React from 'react';
|
||
|
import sinon from 'sinon';
|
||
|
import { shallow } from 'enzyme';
|
||
4 years ago
|
import { DropdownMenuItem } from './dropdown';
|
||
6 years ago
|
|
||
4 years ago
|
describe('Dropdown', () => {
|
||
4 years ago
|
let wrapper;
|
||
|
const onClickSpy = sinon.spy();
|
||
|
const closeMenuSpy = sinon.spy();
|
||
6 years ago
|
|
||
4 years ago
|
beforeEach(() => {
|
||
6 years ago
|
wrapper = shallow(
|
||
|
<DropdownMenuItem
|
||
5 years ago
|
onClick={onClickSpy}
|
||
5 years ago
|
style={{ test: 'style' }}
|
||
5 years ago
|
closeMenu={closeMenuSpy}
|
||
4 years ago
|
/>,
|
||
4 years ago
|
);
|
||
|
});
|
||
6 years ago
|
|
||
4 years ago
|
it('renders li with dropdown-menu-item class', () => {
|
||
|
expect(wrapper.find('li.dropdown-menu-item')).toHaveLength(1);
|
||
4 years ago
|
});
|
||
6 years ago
|
|
||
4 years ago
|
it('adds style based on props passed', () => {
|
||
|
expect(wrapper.prop('style').test).toStrictEqual('style');
|
||
4 years ago
|
});
|
||
6 years ago
|
|
||
4 years ago
|
it('simulates click event and calls onClick and closeMenu', () => {
|
||
4 years ago
|
wrapper.prop('onClick')();
|
||
4 years ago
|
expect(onClickSpy.callCount).toStrictEqual(1);
|
||
|
expect(closeMenuSpy.callCount).toStrictEqual(1);
|
||
4 years ago
|
});
|
||
|
});
|