diff --git a/public/app/features/explore/QueryField.test.tsx b/public/app/features/explore/QueryField.test.tsx new file mode 100644 index 00000000000..9b3e915a93b --- /dev/null +++ b/public/app/features/explore/QueryField.test.tsx @@ -0,0 +1,19 @@ +import React from 'react'; +import { shallow } from 'enzyme'; + +import { QueryField } from './QueryField'; + +describe('', () => { + it('renders with null initial value', () => { + const wrapper = shallow(); + expect(wrapper.find('div').exists()).toBeTruthy(); + }); + it('renders with empty initial value', () => { + const wrapper = shallow(); + expect(wrapper.find('div').exists()).toBeTruthy(); + }); + it('renders with initial value', () => { + const wrapper = shallow(); + expect(wrapper.find('div').exists()).toBeTruthy(); + }); +}); diff --git a/public/app/features/explore/QueryField.tsx b/public/app/features/explore/QueryField.tsx index 06f8c6897ed..1f637c44d59 100644 --- a/public/app/features/explore/QueryField.tsx +++ b/public/app/features/explore/QueryField.tsx @@ -92,7 +92,7 @@ export class QueryField extends React.PureComponent { const { suggestions } = this.state; const menu = this.menuEl; + // Exit for unit tests + if (!window.getSelection) { + return; + } const selection = window.getSelection(); const node = selection.anchorNode;