-
Notifications
You must be signed in to change notification settings - Fork 148
Expand file tree
/
Copy pathcustom-init.js
More file actions
68 lines (54 loc) · 1.77 KB
/
custom-init.js
File metadata and controls
68 lines (54 loc) · 1.77 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
describe('an image at x0, y4000, lazyload stored as `customlzld`, 500px offset, youpikai as data-src ', function() {
require('./fixtures/bootstrap.js');
beforeEach(h.clean);
afterEach(h.clean);
var lazyAttr = 'youpikai';
var lazyFunc = 'customlzld';
var fakeSrc = '../b.gif?'+(+new Date());
var realSrc = '/test/fixtures/tiny.gif?'+(+new Date());
var offset = 500;
var scrollTo = 4000 -
document.documentElement.clientHeight -
offset;
var test;
window[lazyFunc] = true;
beforeEach(function() {
window[lazyFunc] = lazyload({
offset: offset,
src: lazyAttr
});
test = h.createTest({
tagName: 'img',
attributes: {
id: 'custom-init',
src: fakeSrc,
'youpikai': realSrc,
width: 10,
height: 10,
onload: lazyFunc + '(this)'
},
style: {
top: '4000px'
}
});
h.insertTest(test);
});
it('does not loads the image at first', h.eltNotLoaded('custom-init', lazyAttr));
describe('when scrolling 1000 pixels', function() {
beforeEach(h.scroller(0, 1000));
it('does not loads the image', h.eltNotLoaded('custom-init', lazyAttr));
});
describe('when scrolling 1px the triggering scroll position ('+(scrollTo-1)+'px)', function() {
beforeEach(h.scroller(0, scrollTo - 1));
it('still does not loads the image', h.eltNotLoaded('custom-init', lazyAttr));
});
describe('when scrolling at the triggering scroll position ('+scrollTo+'px)', function() {
beforeEach(h.scroller(0, scrollTo));
beforeEach(h.wait(50));
beforeEach(h.scroller(0, scrollTo + 1));
beforeEach(h.wait(50));
beforeEach(h.scroller(0, scrollTo + 10));
beforeEach(h.wait(50));
it('loads the image', h.eltLoaded('custom-init', lazyAttr));
});
});