-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Expand file tree
/
Copy pathscrollTo.js
More file actions
executable file
·49 lines (41 loc) · 1.68 KB
/
scrollTo.js
File metadata and controls
executable file
·49 lines (41 loc) · 1.68 KB
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
'use strict';
describe('scrollTo.js', function () {
describe('scrolls to line', function () {
// create a new pad with URL hash set before each test run
before(async function () {
await helper.aNewPad({hash: 'L4'});
});
it('Scrolls down to Line 4', async function () {
const chrome$ = helper.padChrome$;
await helper.waitForPromise(() => {
const topOffset = parseInt(chrome$('iframe').first('iframe')
.contents().find('#outerdocbody').css('top'));
return (topOffset >= 100);
});
});
it('reapplies the scroll when earlier content changes height after load', async function () {
const chrome$ = helper.padChrome$;
const inner$ = helper.padInner$;
const getTopOffset = () => parseInt(chrome$('iframe').first('iframe')
.contents().find('#outerdocbody').css('top')) || 0;
await helper.waitForPromise(() => getTopOffset() >= 100);
const initialTopOffset = getTopOffset();
inner$('#innerdocbody > div').first().css('height', '400px');
await helper.waitForPromise(() => getTopOffset() > initialTopOffset + 200);
});
});
describe('doesnt break on weird hash input', function () {
// create a new pad with URL hash set before each test run
before(async function () {
await helper.aNewPad({hash: '#DEEZ123123NUTS'});
});
it('Does NOT change scroll', async function () {
const chrome$ = helper.padChrome$;
await helper.waitForPromise(() => {
const topOffset = parseInt(chrome$('iframe').first('iframe')
.contents().find('#outerdocbody').css('top'));
return (!topOffset); // no css top should be set.
});
});
});
});