-
Notifications
You must be signed in to change notification settings - Fork 148
Expand file tree
/
Copy path404.js
More file actions
48 lines (42 loc) · 1.18 KB
/
404.js
File metadata and controls
48 lines (42 loc) · 1.18 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
// https://github.com/vvo/lazyload/issues/62
describe('when an image resolves to 404', function() {
require('./fixtures/bootstrap.js');
beforeEach(h.clean);
afterEach(h.clean);
var fakeSrc = '../b.gif?'+(+new Date());
var standardSrc = '/IDONOTEXISTSLOL.gif?'+(+new Date());
var lazyFunc = 'customCallback';
var calls = 0;
var test;
window[lazyFunc] = true;
beforeEach(function() {
window[lazyFunc] = lazyload({
src: function(elt) {
calls++;
return elt.getAttribute('data-src');
}
});
test = h.createTest({
tagName: 'img',
attributes: {
id: 'custom-callback',
src: fakeSrc,
'data-src': standardSrc,
width: 10,
height: 10,
onload: lazyFunc+'(this)',
onerror: 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 only once (no infinite loop)', function() {
assert.equal(calls, 1, 'We should have called the callback only once');
});
});
});