dropdownAutoComplete.spec.jsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import React from 'react';
  2. import {mount} from 'enzyme';
  3. import DropdownAutoComplete from 'app/components/dropdownAutoComplete';
  4. describe('DropdownAutoComplete', function() {
  5. const routerContext = TestStubs.routerContext();
  6. it('has actor wrapper', function() {
  7. const wrapper = mount(
  8. <DropdownAutoComplete
  9. items={[
  10. {
  11. value: 'apple',
  12. label: <div>Apple</div>,
  13. },
  14. {
  15. value: 'bacon',
  16. label: <div>Bacon</div>,
  17. },
  18. {
  19. value: 'corn',
  20. label: <div>Corn</div>,
  21. },
  22. ]}
  23. >
  24. {() => 'Click Me!'}
  25. </DropdownAutoComplete>,
  26. routerContext
  27. );
  28. expect(wrapper.find('div[role="button"]')).toHaveLength(1);
  29. expect(wrapper.find('div[role="button"]').text()).toBe('Click Me!');
  30. });
  31. it('opens dropdown menu when actor is clicked', function() {
  32. const wrapper = mount(
  33. <DropdownAutoComplete
  34. items={[
  35. {
  36. value: 'apple',
  37. label: <div>Apple</div>,
  38. },
  39. {
  40. value: 'bacon',
  41. label: <div>Bacon</div>,
  42. },
  43. {
  44. value: 'corn',
  45. label: <div>Corn</div>,
  46. },
  47. ]}
  48. >
  49. {() => 'Click Me!'}
  50. </DropdownAutoComplete>,
  51. routerContext
  52. );
  53. wrapper.find('Actor[role="button"]').simulate('click');
  54. expect(wrapper.find('StyledMenu')).toHaveLength(1);
  55. });
  56. });