From: Karim Hamidou Date: Tue, 8 Nov 2011 10:27:22 +0000 (+0100) Subject: added unit tests for mediafragment plugin X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=17633e72937572b5cf4f1d3507b0e81fe402279d;p=popcorn-js.git added unit tests for mediafragment plugin --- diff --git a/plugins/mediafragment/popcorn.mediafragment.unit.html b/plugins/mediafragment/popcorn.mediafragment.unit.html new file mode 100644 index 0000000..ff07abb --- /dev/null +++ b/plugins/mediafragment/popcorn.mediafragment.unit.html @@ -0,0 +1,48 @@ + + + + Popcorn API + + + + + + + + + + +

Popcorn Mediafragment Plugin

+

+
+

+
    +
    + + +
    +
    + + diff --git a/plugins/mediafragment/popcorn.mediafragment.unit.js b/plugins/mediafragment/popcorn.mediafragment.unit.js new file mode 100644 index 0000000..0fff2b3 --- /dev/null +++ b/plugins/mediafragment/popcorn.mediafragment.unit.js @@ -0,0 +1,53 @@ +test( "Popcorn Footnote Plugin", function() { + + var popped = Popcorn( "#video" ), + expects = 3, + count = 0; + + expect( expects ); + + function plus() { + if ( ++count===expects ) { + start(); + } + } + + stop(); + + ok( "mediafragment" in popped, "mediafragment is a method of the popped instance" ); + plus(); + + var currstate = window.location.href.split("#t="); + equals( currstate[1], undefined, "initially, there is no # in the url" ); + plus(); + + popped.mediafragment({ + start: 0, + }); + + popped.exec( 2, function() { + popped.pause(); + popped.play(); + + + }); + + popped.exec( 3, function() { + var currstate = window.location.href.split("#t="); + console.log(currstate); + var time = + currstate[1]; + + // popcorn's precision is limited to the second. + ok(time >= 2 && time <= 3, "correct time is set" ); + plus(); + popped.play(); + + }); + + popped.exec( 4, function() { + // clear the address bar + window.location.href = window.location.href.split("#t=")[0]; + }); + + popped.play(); +}); \ No newline at end of file