|
27 | 27 | // This will run before each test in this module.
|
28 | 28 | setup: function () {
|
29 | 29 | this.elems = $('#qunit-fixture');
|
| 30 | + $(window).lazyLoadXT(); |
30 | 31 | }
|
31 | 32 | });
|
32 | 33 |
|
|
35 | 36 | strictEqual(this.elems.lazyLoadXT(), this.elems, 'should be chainable');
|
36 | 37 | });
|
37 | 38 |
|
38 |
| - asyncTest('is lazy loaded', function () { |
| 39 | + asyncTest('is lazy loading', function () { |
39 | 40 | expect(5);
|
| 41 | + var $img = $('img'), |
| 42 | + cntinit = $img.filter(function (index, el) { |
| 43 | + el = el || this; |
| 44 | + return $(el).data('lazied'); |
| 45 | + }).length; |
| 46 | + ok($img.length > 0, 'images should be presented'); |
| 47 | + ok(cntinit > 0, 'images should be initialized'); |
| 48 | + ok(cntinit === $img.length, 'all images should be initialized'); |
40 | 49 | setTimeout(function () {
|
41 | 50 | var $img = $('img'),
|
42 |
| - cntinit = $img.filter(function (index, el) { |
43 |
| - el = el || this; |
44 |
| - return $(el).data('lazied'); |
45 |
| - }).length, |
46 | 51 | cntnow = $img.filter(function (index, el) {
|
47 | 52 | el = el || this;
|
48 |
| - return $(el).data('lazied') && ($(el).attr('src') === $(el).attr('data-src')); |
| 53 | + return ($(el).attr('src') === $(el).attr('data-src')); |
49 | 54 | }).length;
|
50 |
| - ok($img.length > 0, 'images should be presented'); |
51 |
| - ok(cntinit > 0, 'images should be initialized'); |
52 |
| - ok(cntinit === $img.length, 'all images should be initialized'); |
53 | 55 | ok(cntnow > 0, 'some images should be displayed');
|
54 | 56 | ok(cntnow < $img.length, 'not all images should be displayed');
|
55 | 57 | start();
|
56 |
| - }, 300); |
| 58 | + }, 200); |
57 | 59 | });
|
58 | 60 | }(window.jQLight || window.jQuery || window.Zepto || window.$));
|
0 commit comments