aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/desandro/imagesloaded/test/unit
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2018-11-25 09:09:26 +0000
committerMario <mario@mariovavti.com>2018-12-02 10:14:37 +0100
commita0d1ce77dc4a74f42cd68c682af8d2d0596cb754 (patch)
tree6065839bbb64f4607ae3c9cf829015283d833bba /vendor/desandro/imagesloaded/test/unit
parent863cae1bab2749f2a829d01989dd501cb4742e16 (diff)
downloadvolse-hubzilla-a0d1ce77dc4a74f42cd68c682af8d2d0596cb754.tar.gz
volse-hubzilla-a0d1ce77dc4a74f42cd68c682af8d2d0596cb754.tar.bz2
volse-hubzilla-a0d1ce77dc4a74f42cd68c682af8d2d0596cb754.zip
update imagesloaded to version 4.1.4 via composer
(cherry picked from commit c667572d3eedb0c31b29a4c469b378ccdcee0ba1)
Diffstat (limited to 'vendor/desandro/imagesloaded/test/unit')
-rw-r--r--vendor/desandro/imagesloaded/test/unit/append.js30
-rw-r--r--vendor/desandro/imagesloaded/test/unit/background.js70
-rw-r--r--vendor/desandro/imagesloaded/test/unit/basics.js28
-rw-r--r--vendor/desandro/imagesloaded/test/unit/data-uri.js10
-rw-r--r--vendor/desandro/imagesloaded/test/unit/jquery-fail.js29
-rw-r--r--vendor/desandro/imagesloaded/test/unit/jquery-success.js28
-rw-r--r--vendor/desandro/imagesloaded/test/unit/local-files.js31
-rw-r--r--vendor/desandro/imagesloaded/test/unit/no-images.js11
-rw-r--r--vendor/desandro/imagesloaded/test/unit/non-element.js24
-rw-r--r--vendor/desandro/imagesloaded/test/unit/selector-string.js12
-rw-r--r--vendor/desandro/imagesloaded/test/unit/single-element.js11
11 files changed, 284 insertions, 0 deletions
diff --git a/vendor/desandro/imagesloaded/test/unit/append.js b/vendor/desandro/imagesloaded/test/unit/append.js
new file mode 100644
index 000000000..7a6b3c827
--- /dev/null
+++ b/vendor/desandro/imagesloaded/test/unit/append.js
@@ -0,0 +1,30 @@
+QUnit.test( 'append', function( assert ) {
+ 'use strict';
+
+ var imgUrls = [
+ 'http://i.imgur.com/bwy74ok.jpg',
+ 'http://i.imgur.com/bAZWoqx.jpg',
+ 'http://i.imgur.com/PgmEBSB.jpg',
+ 'http://i.imgur.com/aboaFoB.jpg',
+ 'http://i.imgur.com/LkmcILl.jpg',
+ 'http://i.imgur.com/q9zO6tw.jpg'
+ ];
+
+ // create images
+ var fragment = document.createDocumentFragment();
+ for ( var i=0, len = imgUrls.length; i < len; i++ ) {
+ var img = document.createElement('img');
+ img.src = imgUrls[i];
+ fragment.appendChild( img );
+ }
+
+ var elem = document.querySelector('#append');
+ elem.appendChild( fragment );
+ var done = assert.async();
+
+ imagesLoaded( elem, { debug: false } ).on( 'always', function() {
+ assert.ok( 'appended images loaded' );
+ done();
+ });
+
+});
diff --git a/vendor/desandro/imagesloaded/test/unit/background.js b/vendor/desandro/imagesloaded/test/unit/background.js
new file mode 100644
index 000000000..ca76fad6f
--- /dev/null
+++ b/vendor/desandro/imagesloaded/test/unit/background.js
@@ -0,0 +1,70 @@
+QUnit.test( 'background', function( assert ) {
+ 'use strict';
+
+ // from Modernizr
+ var supportsMultiBGs = ( function() {
+ var style = document.createElement('a').style;
+ style.cssText = 'background:url(https://),url(https://),red url(https://)';
+ return (/(url\s*\(.*?){3}/).test(style.background);
+ })();
+
+ var multiBGCount = supportsMultiBGs ? 3 : 0;
+ var done = assert.async( 14 + multiBGCount );
+
+ var imgLoad0 = imagesLoaded( '#background .tulip', { background: true }, function() {
+ assert.ok( true, 'callback triggered on .orange-tree');
+ done();
+ });
+ assert.equal( imgLoad0.images.length, 1, '1 image on .images' );
+
+ imgLoad0.on( 'progress', function( instance, image, element ) {
+ assert.ok( element.nodeName == 'DIV', 'progress; element is div');
+ assert.ok( image.isLoaded, 'progress; image.isLoaded');
+ done();
+ });
+
+ var imgLoad1 = imagesLoaded( '#background .thunder-cloud', { background: true }, function() {
+ assert.ok( true, 'callback triggered on .thunder-cloud');
+ done();
+ });
+ assert.equal( imgLoad1.images.length, 1, '1 image on .images' );
+
+ // multiple backgrounds
+ var imgLoad2 = imagesLoaded( '#background .multi', { background: true }, function() {
+ assert.ok( true, 'callback triggered on .multi');
+ done();
+ });
+ assert.equal( imgLoad2.images.length, multiBGCount, 'correct multiple BG count on .images' );
+
+ // multiple elements
+ var imgLoad3 = imagesLoaded( '#background .bg-box', { background: true }, function() {
+ assert.ok( true, 'callback triggered on .bg-box');
+ var count = 5 + multiBGCount;
+ assert.equal( imgLoad3.images.length, count, count + ' images on .bg-box' );
+ done();
+ });
+
+ imgLoad3.on('progress', function( instance, image/*, element */) {
+ assert.ok( true, 'progress on .bg-box; ' + image.img.src );
+ assert.equal( image.isLoaded, true, 'image.isLoaded == true' );
+ done();
+ });
+
+ // background and <img> children
+ var imgLoad4 = imagesLoaded( '#background .gulls', { background: true } );
+ assert.equal( imgLoad4.images.length, 3, '3 images: 1 background and 2 <img>' );
+
+ imgLoad4.on( 'progress', function( instance, image ) {
+ assert.equal( image.isLoaded, true, 'image is loaded' );
+ done();
+ });
+
+ // child background selector
+ var imgLoad5 = imagesLoaded( '#background', { background: '.bg-box' }, function() {
+ var count = 5 + multiBGCount;
+ assert.equal( imgLoad5.images.length, count,
+ count + ' images on .bg-box, with {background: .bg-box}' );
+ done();
+ });
+
+});
diff --git a/vendor/desandro/imagesloaded/test/unit/basics.js b/vendor/desandro/imagesloaded/test/unit/basics.js
new file mode 100644
index 000000000..6c502a793
--- /dev/null
+++ b/vendor/desandro/imagesloaded/test/unit/basics.js
@@ -0,0 +1,28 @@
+QUnit.test( 'basics', function( assert ) {
+
+ 'use strict';
+
+ var elem = document.querySelector('#basics');
+ var images = elem.querySelectorAll('img');
+ var done = assert.async( 3 + images.length );
+
+ var imgLoader = new imagesLoaded( elem, function( obj ) {
+ assert.ok( true, 'callback function triggered' );
+ assert.equal( imgLoader, obj, 'callback argument and instance match' );
+ done();
+ });
+ imgLoader.on( 'done', function() {
+ assert.ok( true, 'done event triggered' );
+ done();
+ });
+ imgLoader.on( 'always', function() {
+ assert.ok( true, 'always event triggered' );
+ done();
+ });
+
+ imgLoader.on( 'progress', function( loader, image ) {
+ assert.ok( image.isLoaded, 'image is loaded');
+ done();
+ });
+
+});
diff --git a/vendor/desandro/imagesloaded/test/unit/data-uri.js b/vendor/desandro/imagesloaded/test/unit/data-uri.js
new file mode 100644
index 000000000..635f69859
--- /dev/null
+++ b/vendor/desandro/imagesloaded/test/unit/data-uri.js
@@ -0,0 +1,10 @@
+QUnit.test( 'data-uri', function( assert ) {
+ 'use strict';
+
+ var done = assert.async();
+ imagesLoaded('#data-uri', { debug: false }).on( 'done', function( obj ) {
+ assert.ok( true, 'data-uri images loaded' );
+ assert.equal( obj.images.length, 2, 'instance has 2 images' );
+ done();
+ });
+});
diff --git a/vendor/desandro/imagesloaded/test/unit/jquery-fail.js b/vendor/desandro/imagesloaded/test/unit/jquery-fail.js
new file mode 100644
index 000000000..b2180f6f2
--- /dev/null
+++ b/vendor/desandro/imagesloaded/test/unit/jquery-fail.js
@@ -0,0 +1,29 @@
+QUnit.test( 'jquery fail', function( assert ) {
+
+ 'use strict';
+
+ var $ = window.jQuery;
+ var $images = $('#jquery-fail img');
+ var done = assert.async( 3 + $images.length );
+
+ $('#jquery-fail').imagesLoaded( function( instance ) {
+ assert.ok( true, 'callback triggered' );
+ assert.ok( instance instanceof imagesLoaded, 'instance instanceof imagesLoaded' );
+ done();
+ })
+ .fail( function( instance ) {
+ assert.ok( true, 'fail triggered' );
+ assert.ok( instance instanceof imagesLoaded, 'instance instanceof imagesLoaded' );
+ done();
+ })
+ .always( function( instance ) {
+ assert.ok( true, 'always triggered' );
+ assert.ok( instance instanceof imagesLoaded, 'instance instanceof imagesLoaded' );
+ done();
+ })
+ .progress( function(/* instance, image */) {
+ assert.ok( true, 'progress trigged');
+ done();
+ });
+
+ });
diff --git a/vendor/desandro/imagesloaded/test/unit/jquery-success.js b/vendor/desandro/imagesloaded/test/unit/jquery-success.js
new file mode 100644
index 000000000..f16621088
--- /dev/null
+++ b/vendor/desandro/imagesloaded/test/unit/jquery-success.js
@@ -0,0 +1,28 @@
+QUnit.test( 'jquery success', function( assert ) {
+
+ 'use strict';
+
+ var $ = window.jQuery;
+ var done = assert.async( 6 );
+
+ $('#jquery-success').imagesLoaded( function( instance ) {
+ assert.ok( true, 'callback triggered' );
+ assert.ok( instance instanceof imagesLoaded, 'instance instanceof imagesLoaded' );
+ done();
+ })
+ .done( function( instance ) {
+ assert.ok( true, 'done triggered' );
+ assert.ok( instance instanceof imagesLoaded, 'instance instanceof imagesLoaded' );
+ done();
+ })
+ .always( function( instance ) {
+ assert.ok( true, 'always triggered' );
+ assert.ok( instance instanceof imagesLoaded, 'instance instanceof imagesLoaded' );
+ done();
+ })
+ .progress( function( instance, image ) {
+ assert.ok( image.isLoaded, 'progress trigged, image is loaded');
+ done();
+ });
+
+});
diff --git a/vendor/desandro/imagesloaded/test/unit/local-files.js b/vendor/desandro/imagesloaded/test/unit/local-files.js
new file mode 100644
index 000000000..61da6ae92
--- /dev/null
+++ b/vendor/desandro/imagesloaded/test/unit/local-files.js
@@ -0,0 +1,31 @@
+QUnit.test( 'local files', function( assert ) {
+ 'use strict';
+
+ var elem = document.querySelector('#locals');
+ var done = assert.async( 6 );
+
+ var imgLoader = new imagesLoaded( elem, function( obj ) {
+ assert.ok( true, 'callback function triggered' );
+ assert.equal( imgLoader, obj, 'callback argument and instance match' );
+ done();
+ });
+ imgLoader.on( 'fail', function() {
+ assert.ok( true, 'fail event triggered' );
+ done();
+ });
+ imgLoader.on( 'always', function() {
+ assert.ok( true, 'always event triggered' );
+ done();
+ });
+
+ imgLoader.on( 'progress', function( loader, image ) {
+ assert.ok( true, 'image progressed');
+ if ( image.img.src.indexOf('img/not-there.jpg') !== -1 ) {
+ assert.ok( !image.isLoaded, 'thunder cloud is not loaded' );
+ } else {
+ assert.ok( image.isLoaded, 'image is loaded' );
+ }
+ done();
+ });
+
+});
diff --git a/vendor/desandro/imagesloaded/test/unit/no-images.js b/vendor/desandro/imagesloaded/test/unit/no-images.js
new file mode 100644
index 000000000..841216381
--- /dev/null
+++ b/vendor/desandro/imagesloaded/test/unit/no-images.js
@@ -0,0 +1,11 @@
+QUnit.test( 'no images', function( assert ) {
+ 'use strict';
+
+ var elem = document.querySelector('#no-images');
+ var done = assert.async();
+ imagesLoaded( elem, function() {
+ assert.ok( true, 'triggered with no images' );
+ done();
+ });
+
+});
diff --git a/vendor/desandro/imagesloaded/test/unit/non-element.js b/vendor/desandro/imagesloaded/test/unit/non-element.js
new file mode 100644
index 000000000..4c9986fa6
--- /dev/null
+++ b/vendor/desandro/imagesloaded/test/unit/non-element.js
@@ -0,0 +1,24 @@
+QUnit.test( 'dismiss non-element nodes', function( assert ) {
+ 'use strict';
+
+ var $ = window.jQuery;
+ var done = assert.async( 2 );
+
+ $(' <img src="https://picsum.photos/401/301/?random" /> <img src="https://picsum.photos/402/302/?random" /> ')
+ .imagesLoaded(function() {
+ assert.ok( true, 'elements from jQuery string ok' );
+ done();
+ });
+
+ // test fragment
+ var frag = document.createDocumentFragment();
+ var img = new Image();
+ img.src = 'https://picsum.photos/403/303/?random';
+ frag.appendChild( img );
+ var imgLoad = imagesLoaded( frag, function() {
+ assert.ok( true, 'document fragment ok' );
+ assert.equal( imgLoad.images.length, 1, '1 image found' );
+ done();
+ });
+
+});
diff --git a/vendor/desandro/imagesloaded/test/unit/selector-string.js b/vendor/desandro/imagesloaded/test/unit/selector-string.js
new file mode 100644
index 000000000..8c43c4bef
--- /dev/null
+++ b/vendor/desandro/imagesloaded/test/unit/selector-string.js
@@ -0,0 +1,12 @@
+QUnit.test( 'selector string', function( assert ) {
+ 'use strict';
+ var images = document.querySelectorAll('#basics img');
+ var done = assert.async();
+ var imgLoad = imagesLoaded('#basics', { debug: true }).on( 'done', function( obj ) {
+ assert.ok( true, 'selector string worked' );
+ assert.ok( obj.images, 'argument has images' );
+ assert.equal( obj.images.length, images.length, 'images.length matches' );
+ done();
+ });
+ assert.ok( imgLoad.options.debug, 'debug option set' );
+});
diff --git a/vendor/desandro/imagesloaded/test/unit/single-element.js b/vendor/desandro/imagesloaded/test/unit/single-element.js
new file mode 100644
index 000000000..42d7e48ee
--- /dev/null
+++ b/vendor/desandro/imagesloaded/test/unit/single-element.js
@@ -0,0 +1,11 @@
+QUnit.test( 'single element', function( assert ) {
+ 'use strict';
+ var elem = document.querySelector('#mario-with-shell');
+ var done = assert.async();
+ imagesLoaded( elem ).on( 'done', function( obj ) {
+ assert.ok( true, 'single element worked' );
+ assert.ok( obj.images, 'argument has images' );
+ assert.equal( obj.images.length, 1, 'images.length = 1' );
+ done();
+ });
+});