diff options
author | Manuel Jiménez Friaza <mjfriaza@openmailbox.org> | 2018-12-05 12:32:33 +0100 |
---|---|---|
committer | Manuel Jiménez Friaza <mjfriaza@openmailbox.org> | 2018-12-05 12:32:33 +0100 |
commit | 4cd5529027efa19288ddce125f0d41ccb5519578 (patch) | |
tree | 69b5bb1b43d807908d38d7febec21732fd334a49 /vendor/desandro/imagesloaded/test/unit/background.js | |
parent | 5ac08ec3aa8ede14141390670a8097a60769e11e (diff) | |
parent | d12744011affe7f6b79201442ad9fce6e083bdbb (diff) | |
download | volse-hubzilla-4cd5529027efa19288ddce125f0d41ccb5519578.tar.gz volse-hubzilla-4cd5529027efa19288ddce125f0d41ccb5519578.tar.bz2 volse-hubzilla-4cd5529027efa19288ddce125f0d41ccb5519578.zip |
Merge remote-tracking branch 'upstream/dev' into dev
Diffstat (limited to 'vendor/desandro/imagesloaded/test/unit/background.js')
-rw-r--r-- | vendor/desandro/imagesloaded/test/unit/background.js | 70 |
1 files changed, 70 insertions, 0 deletions
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(); + }); + +}); |