]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#216] tests for removeplugin
authorrwldrn <waldron.rick@gmail.com>
Tue, 14 Dec 2010 18:09:07 +0000 (13:09 -0500)
committerrwldrn <waldron.rick@gmail.com>
Tue, 14 Dec 2010 18:09:07 +0000 (13:09 -0500)
test/popcorn.unit.js

index f60d9a9ec0503828e6b029e8042ab48f69c516d2..e3a60b6e314cbe24529532d79524e311a275748f 100644 (file)
@@ -73,7 +73,7 @@ test("Object", function () {
 
   
   var popped = Popcorn("#video"), 
-      methods = "load play pause currentTime mute volume roundTime exec";
+      methods = "load play pause currentTime mute volume roundTime exec removePlugin";
   
   
   
@@ -444,14 +444,13 @@ test("Plugin Factory", function () {
   // needs expectation
 
   var popped = Popcorn("#video"), 
-      methods = "load play pause currentTime mute volume roundTime exec",
-      expects = 22, 
+      methods = "load play pause currentTime mute volume roundTime exec removePlugin",
+      expects = 24, 
       count = 0;
   
   //expect(expects);
   
   function plus() { 
-    console.log(count);
     if ( ++count == expects ) {
       start(); 
     }
@@ -592,6 +591,10 @@ test("Plugin Factory", function () {
     } 
   });
 
+  ok( "breaker" in popped, "breaker plugin is now available to instance" );
+  plus();
+  ok( Popcorn.registry.length === 3, "Three items in the registry");
+  plus();
   
   popped.breaker({
     start: 1, 
@@ -601,6 +604,44 @@ test("Plugin Factory", function () {
   popped.currentTime(0).play();
 });
 
+test("removePlugin", function () {
+  
+  expect(10);
+  
+  var p = Popcorn("#video"), 
+      rlen = Popcorn.registry.length;
+  
+  equals( rlen, 3, "Popcorn.registry.length is 3");
+  
+  
+  equals( p.data.trackEvents.byStart.length, 2, "p.data.trackEvents.byStart is initialized and has 2 entries");
+  equals( p.data.trackEvents.byEnd.length, 2, "p.data.trackEvents.byEnd is initialized and has 2 entries");
+  
+  p.breaker({
+    start: 2, 
+    end: 30
+  });     
+  
+  equals( p.data.trackEvents.byStart.length, 3, "p.data.trackEvents.byStart is updated and has 3 entries");
+  equals( p.data.trackEvents.byEnd.length, 3, "p.data.trackEvents.byEnd is updated and has 3 entries");
+  
+  
+  p.removePlugin("breaker");
+  
+  
+  ok( !("breaker" in p), "breaker plugin is no longer available to instance" );
+  ok( !("breaker" in Popcorn.prototype), "breaker plugin is no longer available to Popcorn.prototype" );
+  
+  
+  equals( Popcorn.registry.length, 2, "Popcorn.registry.length is 2");
+  
+  equals( p.data.trackEvents.byStart.length, 2, "p.data.trackEvents.byStart is updated and has 2 entries");
+  equals( p.data.trackEvents.byEnd.length, 2, "p.data.trackEvents.byEnd is updated and has 2 entries");
+  
+});
+
+
+
 
 test("Protected Names", function () {