]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#336] added unit tests for unique closure data
authorScottDowne <sdowne@learn.senecac.on.ca>
Wed, 23 Feb 2011 20:24:55 +0000 (15:24 -0500)
committerScottDowne <sdowne@learn.senecac.on.ca>
Wed, 23 Feb 2011 20:28:14 +0000 (15:28 -0500)
test/popcorn.unit.js

index aaa082f87a5c487b073c70b2cf2b96952ab6b8f1..21b74bf11e79ef7de321a5c4e72037f01bb2c585 100755 (executable)
@@ -580,7 +580,7 @@ test("Plugin Factory", function () {
 
   var popped = Popcorn("#video"), 
       methods = "load play pause currentTime mute volume roundTime exec removePlugin",
-      expects = 26, 
+      expects = 48, 
       count = 0;
   
   //expect(expects);
@@ -590,11 +590,13 @@ test("Plugin Factory", function () {
       Popcorn.removePlugin("breaker");
       Popcorn.removePlugin("executor");
       Popcorn.removePlugin("complicator");
+      Popcorn.removePlugin("closure");
       start(); 
     }
   }
 
   stop( 10000 );
+  expect(expects);
 
   Popcorn.plugin("executor", function () {
     
@@ -739,7 +741,46 @@ test("Plugin Factory", function () {
     end: 2
   });     
 
+  Popcorn.plugin("closure", function() {
+
+    var startCount = 0;
+    var endCount = 0;
+
+    return {
+
+      _setup: function( options ) {
+        options.startCount = 0;
+        options.endCount = 0;
+      },
+      start: function ( event, options ) {
+        // test is run four times. Two closure tracks, called twice each
+        equals( startCount++, options.startCount++, options.nick + " has correct start counts" );
+        plus();
+      },
+      end: function ( event, options ) {
+        // test is run four times. Two closure tracks, called twice each
+        equals( endCount++, options.endCount++, options.nick + " has correct end counts" );
+        plus();
+        
+        // running tracks again to make sure data increments uniquly
+        popped.currentTime(5).play();
+      }
+    }; 
+  });
+
+  popped.closure({
+    start: 5,
+    end: 6,
+    nick: "first closure track"
+  })
+  .closure({
+    start: 5,
+    end: 6,
+    nick: "second closure track"
+  });
+
   popped.currentTime(0).play();
+
 });
 
 test("Remove Plugin", function () {