From 2bf2c650e097f6935f7dec6c004f9b1b7655095f Mon Sep 17 00:00:00 2001 From: ScottDowne Date: Tue, 21 Dec 2010 12:52:25 -0500 Subject: [PATCH] [#159] added unit tests for twitter plugin --- plugins/twitter/popcorn.twitter.unit.html | 45 +++++++++++++++++ plugins/twitter/popcorn.twitter.unit.js | 61 +++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 plugins/twitter/popcorn.twitter.unit.html create mode 100644 plugins/twitter/popcorn.twitter.unit.js 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(); + +}); -- 2.43.0