From: rwldrn Date: Tue, 14 Dec 2010 18:09:07 +0000 (-0500) Subject: [#216] tests for removeplugin X-Git-Tag: v0.2~49 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=28597f236f34d7c96a844c514c271ba540b34ff2;p=popcorn-js.git [#216] tests for removeplugin --- diff --git a/test/popcorn.unit.js b/test/popcorn.unit.js index f60d9a9..e3a60b6 100644 --- a/test/popcorn.unit.js +++ b/test/popcorn.unit.js @@ -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 () {