|
@@ -1,6 +1,5 @@
|
|
|
import React from 'react';
|
|
import React from 'react';
|
|
|
import { shallow } from 'enzyme';
|
|
import { shallow } from 'enzyme';
|
|
|
-
|
|
|
|
|
import { QueryField } from './QueryField';
|
|
import { QueryField } from './QueryField';
|
|
|
|
|
|
|
|
describe('<QueryField />', () => {
|
|
describe('<QueryField />', () => {
|
|
@@ -28,4 +27,35 @@ describe('<QueryField />', () => {
|
|
|
expect(handleEnterAndTabKeySpy).toBeCalled();
|
|
expect(handleEnterAndTabKeySpy).toBeCalled();
|
|
|
expect(instance.executeOnChangeAndRunQueries).toBeCalled();
|
|
expect(instance.executeOnChangeAndRunQueries).toBeCalled();
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ it('should copy selected text', () => {
|
|
|
|
|
+ const wrapper = shallow(<QueryField initialQuery="" />);
|
|
|
|
|
+ const instance = wrapper.instance() as QueryField;
|
|
|
|
|
+ const textBlocks = ['ignore this text. copy this text'];
|
|
|
|
|
+ const copiedText = instance.getCopiedText(textBlocks, 18, 32);
|
|
|
|
|
+
|
|
|
|
|
+ expect(copiedText).toBe('copy this text');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('should copy selected text across 2 lines', () => {
|
|
|
|
|
+ const wrapper = shallow(<QueryField initialQuery="" />);
|
|
|
|
|
+ const instance = wrapper.instance() as QueryField;
|
|
|
|
|
+ const textBlocks = ['ignore this text. start copying here', 'lorem ipsum. stop copying here. lorem ipsum'];
|
|
|
|
|
+ const copiedText = instance.getCopiedText(textBlocks, 18, 30);
|
|
|
|
|
+
|
|
|
|
|
+ expect(copiedText).toBe('start copying here\nlorem ipsum. stop copying here');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('should copy selected text across > 2 lines', () => {
|
|
|
|
|
+ const wrapper = shallow(<QueryField initialQuery="" />);
|
|
|
|
|
+ const instance = wrapper.instance() as QueryField;
|
|
|
|
|
+ const textBlocks = [
|
|
|
|
|
+ 'ignore this text. start copying here',
|
|
|
|
|
+ 'lorem ipsum doler sit amet',
|
|
|
|
|
+ 'lorem ipsum. stop copying here. lorem ipsum',
|
|
|
|
|
+ ];
|
|
|
|
|
+ const copiedText = instance.getCopiedText(textBlocks, 18, 30);
|
|
|
|
|
+
|
|
|
|
|
+ expect(copiedText).toBe('start copying here\nlorem ipsum doler sit amet\nlorem ipsum. stop copying here');
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|