-
Notifications
You must be signed in to change notification settings - Fork 1
/
search-selected-text.spec.js
59 lines (49 loc) · 1.97 KB
/
search-selected-text.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* eslint-disable */
import SelectedTextSearchHelper from './search-selected-text';
import jQuery from 'jquery';
document.body.insertAdjacentHTML('beforeend', '<p id="content">This is some sample text</p>');
new SelectedTextSearchHelper().Init();
describe('Search Selected Text Helper', function () {
it('has search button on page', function () {
expect(jQuery('#share-button').length).to.equal(1);
});
it('Shows Search popup on text selection', function (done) {
var range = document.createRange();
const pContent = document.getElementById('content');
range.setStart(pContent.firstChild, 0);
range.setEnd(pContent.firstChild, 10);
var sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
document.onmouseup({ pageY: 50, pageX: 50 });
setTimeout(function () {
const buttonTopNew = jQuery('#share-button').css('top');
const buttonLeftNew = jQuery('#share-button').css('left');
expect(buttonTopNew).to.equal('50px');
expect(buttonLeftNew).to.equal('50px');
var sel = window.getSelection();
sel.removeAllRanges();
done();
}, 100);
});
// it('Hides Search popup on button click', function (done) {
// var range = document.createRange();
// const pContent = document.getElementById('content');
// range.setStart(pContent.firstChild, 0);
// range.setEnd(pContent.firstChild, 10);
// var sel = window.getSelection();
// sel.removeAllRanges();
// sel.addRange(range);
// document.onmouseup({ pageY: 50, pageX: 50 });
// setTimeout(function () {
// jQuery('#share-button').find('button')[0].onmousedown();
// const buttonTopNew = jQuery('#share-button').css('top');
// const buttonLeftNew = jQuery('#share-button').css('left');
// expect(buttonTopNew).to.equal('-9999px');
// expect(buttonLeftNew).to.equal('-9999px');
// var sel = window.getSelection();
// sel.removeAllRanges();
// done();
// }, 100);
// });
});