From: ScottDowne Date: Tue, 21 Dec 2010 17:52:25 +0000 (-0500) Subject: [#159] added unit tests for twitter plugin X-Git-Tag: v0.2~22^2~3^2~6 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=2bf2c650e097f6935f7dec6c004f9b1b7655095f;p=popcorn-js.git [#159] added unit tests for twitter plugin --- diff --git a/plugins/twitter/popcorn.twitter.unit.html b/plugins/twitter/popcorn.twitter.unit.html new file mode 100644 index 0000000..e03f454 --- /dev/null +++ b/plugins/twitter/popcorn.twitter.unit.html @@ -0,0 +1,45 @@ + + + + Popcorn API + + + + + + + + + + + + +

Popcorn Twitter Plugin

+

+
+

+
    +
    + + +
    + + diff --git a/plugins/twitter/popcorn.twitter.unit.js b/plugins/twitter/popcorn.twitter.unit.js new file mode 100644 index 0000000..b3eed37 --- /dev/null +++ b/plugins/twitter/popcorn.twitter.unit.js @@ -0,0 +1,61 @@ +test("Popcorn Twitter Plugin", function () { + + var popped = Popcorn("#video"), + expects = 6, + count = 0, + interval, + interval2, + twitterdiv = document.getElementById('twitterdiv'); + + expect( expects ); + + function plus() { + if ( ++count === expects) { + start(); + } + } + + stop(); + + ok('twitter' in popped, "twitter is a method of the popped instance"); + plus(); + + equals ( twitterdiv.innerHTML, "", "initially, there is nothing inside the twitterdiv" ); + plus(); + + try { + + ok( TWTR, "Twitter constructor exists"); + plus(); + + } catch (e) {}; + + popped.twitter({ + start: 1, // seconds + end: 3, // seconds + title: 'Steve Song', + src: '@stevesong', + target: 'twitterdiv', + } ); + + interval = setInterval( function() { + if( popped.currentTime() > 1 && popped.currentTime() < 3 ) { + ok( /display: inline;/.test( twitterdiv.innerHTML ), "Div contents are displayed" ); + plus(); + ok( /twtr-widget/.test( twitterdiv.innerHTML ), "A Twitter widget exists" ); + plus(); + clearInterval( interval ); + } + }, 500); + + interval2 = setInterval( function() { + if( popped.currentTime() > 3 ) { + ok( /display: none;/.test( twitterdiv.innerHTML ), "Div contents are hidden again" ); + plus(); + clearInterval( interval2 ); + } + }, 500); + + popped.play(); + +});