-
Notifications
You must be signed in to change notification settings - Fork 148
Expand file tree
/
Copy pathcustom-callback.js
More file actions
54 lines (46 loc) · 1.3 KB
/
custom-callback.js
File metadata and controls
54 lines (46 loc) · 1.3 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
describe('giving a specific callback', function() {
require('./fixtures/bootstrap.js');
beforeEach(h.clean);
afterEach(h.clean);
var fakeSrc = '../b.gif?'+(+new Date());
var standardSrc = '/test/fixtures/tiny.gif?'+(+new Date());
var hdSrc = '/test/fixtures/tiny.gif?HD&'+(+new Date());
var lazyFunc = 'customCallback';
var called;
var test;
window[lazyFunc] = true;
beforeEach(function() {
window[lazyFunc] = lazyload({
src: function(elt) {
called = true;
return elt.getAttribute('data-hdSrc');
}
});
test = h.createTest({
tagName: 'img',
attributes: {
id: 'custom-callback',
src: fakeSrc,
'data-src': standardSrc,
'data-hdSrc': hdSrc,
width: 10,
height: 10,
onload: lazyFunc+'(this)'
}
});
h.insertTest(test);
});
describe('after some scrolling', function() {
beforeEach(h.scroller(0, 50));
beforeEach(h.wait(200));
beforeEach(h.scroller(0, 0));
beforeEach(h.wait(200));
it('custom callback was called', function() {
assert(called === true);
});
it('loads the image when visible for a while', h.eltLoaded('custom-callback'));
it('has loaded the hdSrc image', function() {
assert(test.src.indexOf(hdSrc) !== -1);
});
});
});