]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
#485 Added unit tests to make sure the order of the images created appear in the...
authorMohammed Buttu <mohammedbuttu@gmail.com>
Tue, 17 May 2011 19:53:06 +0000 (15:53 -0400)
committerMohammed Buttu <mohammedbuttu@gmail.com>
Tue, 17 May 2011 19:53:06 +0000 (15:53 -0400)
plugins/image/popcorn.image.unit.js

index 3d31a10d78f347ecc2ed3ddbcb35390aaae13bde..aadd3bebbf74c1a6ef54fd65662ac7de4ad283c9 100644 (file)
@@ -1,9 +1,14 @@
 test("Popcorn Image Plugin", function () {
   
   var popped = Popcorn( "#video" ),
-      expects = 5,
+      expects = 8,
       count = 0,
-      imagediv = document.getElementById( "imagediv" );
+      imagediv = document.getElementById( "imagediv" ),
+      sources = [
+        "https://www.drumbeat.org/media//images/drumbeat-logo-splash.png",
+        "http://www.petmountain.com/category/mini/organic-dog-supplies/520/organic-dog-supplies.jpg", 
+        "http://www.botskool.com/sites/default/files/images/javascript.png"
+      ];
   
   expect( expects );
   
@@ -27,22 +32,48 @@ test("Popcorn Image Plugin", function () {
     // seconds
     end: 3,
     href: "http://www.drumbeat.org/",
-    src: "https://www.drumbeat.org/media//images/drumbeat-logo-splash.png",
+    src: sources[0],
     text: "DRUMBEAT",
     target: "imagediv"
+  })
+  .image({
+    // seconds
+    start: 4,
+    // seconds
+    end: 6,
+    // no href
+    src: sources[1],
+    target: "imagediv"
+  })
+  .image({
+    // seconds
+    start: 4,
+    // seconds
+    end: 6,
+    // no href
+    src: sources[2],
+    target: "imagediv"  
   });
 
   popped.exec( 2, function() {
-      ok( /display: block;/.test( imagediv.innerHTML ), "Div contents are displayed" );
-      plus();
-      ok( /img/.test( imagediv.innerHTML ), "An image exists" );
-      plus();
+    ok( /display: block;/.test( imagediv.innerHTML ), "Div contents are displayed" );
+    plus();
+    ok( /img/.test( imagediv.innerHTML ), "An image exists" );
+    plus();
   });
   
   popped.exec( 4, function() {
-      ok( /display: none;/.test( imagediv.innerHTML ), "Div contents are hidden again" );
+    ok( /display: none;/.test( imagediv.innerHTML ), "Div contents are hidden again" );
+    plus();
+  });
+  
+  popped.exec( 5, function() {
+    [].forEach.call( document.querySelectorAll( "#imagediv a img" ), function( img, idx ) {
+      alert(idx);
+      ok( img.src === sources[ idx ], "Image " + idx + " is in the right order" );
       plus();
+    });
   });
-
+  
   popped.volume( 0 ).play();  
 });