From: David Seifried Date: Tue, 13 Sep 2011 16:04:53 +0000 (-0400) Subject: Moved unit tests a bit X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=45a2401b810d4e933ef2606e0208d7813e8ba966;p=popcorn-js.git Moved unit tests a bit --- diff --git a/test/popcorn.unit.js b/test/popcorn.unit.js index 1440522..f5928ca 100644 --- a/test/popcorn.unit.js +++ b/test/popcorn.unit.js @@ -52,7 +52,7 @@ test("API", function () { test("Popcorn.* Static Methods", function () { var statics = [ "forEach", "extend", "error", "guid", "sizeOf", "nop", - "addTrackEvent", "removeTrackEvent", "getTrackEvents", "getTrackEvent", "position", "disable", "enable" ], + "addTrackEvent", "removeTrackEvent", "getTrackEvents", "getTrackEvent", "position", "disable", "enable", "timeUpdate" ], substatics = [ "addTrackEvent", "removeTrackEvent", "getTrackEvents", "getTrackEvent"]; expect(statics.length + substatics.length); @@ -1647,6 +1647,57 @@ test("Update Timer", function () { }); + +test("timeUpdate add track event while paused", function() { + + var $pop = Popcorn( "#video" ), + count = 0, + expects = 3; + + expect( expects ); + + function plus() { + if ( ++count === expects ) { + Popcorn.removePlugin( "timeUpdateTester" ); + Popcorn.removeInstance( $pop ); + } + } + + Popcorn.plugin("timeUpdateTester", function() { + return { + start: function () { + var div = document.createElement("div"); + div.id = "timeUpdate-test"; + + document.body.appendChild(div); + }, + end: function () { + document.getElementById("timeUpdate-test").parentNode.removeChild(document.getElementById("timeUpdate-test")); + } + }; + }); + + $pop.currentTime(40).pause(); + + equals( $pop.getTrackEvents().length, 0, "Initially no trackEvents" ); + plus(); + + $pop.timeUpdateTester({ + id:"timeUpdateID", + start:40, + end: 41 + }); + + equals( $pop.getTrackEvents().length, 1, "trackEvent successfully added" ); + plus(); + + ok( document.getElementById( "timeUpdate-test" ), "trackEvent successfully added, content was displayed while video was paused" ); + plus(); + + $pop.removeTrackEvent( "timeUpdateID" ); + +}); + test("Plugin Factory", function () { QUnit.reset(); @@ -2627,49 +2678,6 @@ test("Index Integrity", function () { }); -test("timeUpdate functionality", function() { - - var $pop = Popcorn( "#video" ), - count = 0, - expects = 4; - - expect( expects ); - - Popcorn.plugin("timeUpdateTester", function() { - return { - start: function () { - var div = document.createElement("div"); - div.id = "timeUpdate-test"; - - document.body.appendChild(div); - }, - end: function () { - document.getElementById("timeUpdate-test").parentNode.removeChild(document.getElementById("timeUpdate-test")); - } - }; - }); - - equals( typeof Popcorn.timeUpdate, "function", "timeUpdate is a function of Popcorn" ); - - $pop.currentTime(40).pause(); - - equals( $pop.getTrackEvents().length, 0, "Initially no trackEvents" ); - - $pop.timeUpdateTester({ - id:"timeUpdateID", - start:40, - end: 41 - }); - - equals( $pop.getTrackEvents().length, 1, "trackEvent successfully added" ); - - ok( document.getElementById( "timeUpdate-test" ), "trackEvent successfully added, content was displayed while video was paused" ); - - $pop.removeTrackEvent( "timeUpdateID" ); - Popcorn.removeInstance( $pop ); - -}); - test("Popcorn.disable/enable/toggle", function() {