import React from 'react'; import {mount} from 'enzyme'; import DropdownAutoComplete from 'app/components/dropdownAutoComplete'; describe('DropdownAutoComplete', function() { const routerContext = TestStubs.routerContext(); const items = [ { value: 'apple', label:
Apple
, }, { value: 'bacon', label:
Bacon
, }, { value: 'corn', label:
Corn
, }, ]; it('has actor wrapper', function() { const wrapper = mount( {() => 'Click Me!'}, routerContext ); expect(wrapper.find('div[role="button"]')).toHaveLength(1); expect(wrapper.find('div[role="button"]').text()).toBe('Click Me!'); }); it('opens dropdown menu when actor is clicked', function() { const wrapper = mount( {() => 'Click Me!'}, routerContext ); wrapper.find('Actor[role="button"]').simulate('click'); expect(wrapper.find('BubbleWithMinWidth')).toHaveLength(1); wrapper.find('Actor[role="button"]').simulate('click'); expect(wrapper.find('BubbleWithMinWidth')).toHaveLength(1); }); it('toggles dropdown menu when actor is clicked', function() { const wrapper = mount( {() => 'Click Me!'} , routerContext ); wrapper.find('Actor[role="button"]').simulate('click'); expect(wrapper.find('BubbleWithMinWidth')).toHaveLength(1); wrapper.find('Actor[role="button"]').simulate('click'); expect(wrapper.find('BubbleWithMinWidth')).toHaveLength(0); }); });