From: ScottDowne Date: Mon, 7 Mar 2011 21:35:01 +0000 (-0500) Subject: [#374] example unit test with exec vs interval X-Git-Tag: v0.4~16^2~2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=c6e0299e102322588da39287e97952a6f23e8879;p=popcorn-js.git [#374] example unit test with exec vs interval --- diff --git a/plugins/attribution/popcorn.attribution.unit.js b/plugins/attribution/popcorn.attribution.unit.js index 3197770..adfeeaf 100644 --- a/plugins/attribution/popcorn.attribution.unit.js +++ b/plugins/attribution/popcorn.attribution.unit.js @@ -3,11 +3,10 @@ test("Popcorn attribution Plugin", function () { var popped = Popcorn("#video"), expects = 7, count = 0, - interval, - interval2, - interval3, attributiondiv = document.getElementById('attribdiv'); +console.log(expects); + expect(expects); function plus() { @@ -44,36 +43,27 @@ test("Popcorn attribution Plugin", function () { licenseurl: "http://creativecommons.org/licenses/by-nc-nd/2.0/", target: 'attribdiv' } ) - .volume(0) - .play(); + .volume(0); + + popped.exec( 1, function() { + equals ( attributiondiv.childElementCount, 2, "attributiondiv now has two inner elements" ); + plus(); + equals (attributiondiv.children[0].style.display , "inline", "attribution is visible on the page" ); + plus(); + }); + popped.exec( 4, function() { + equals (attributiondiv.children[1].style.display , "inline", "second attribution is visible on the page" ); + plus(); + }); - interval = setInterval( function() { - if( popped.currentTime() > 0 && popped.currentTime() <= 5 ) { - equals ( attributiondiv.childElementCount, 2, "attributiondiv now has two inner elements" ); - plus(); - equals (attributiondiv.children[0].style.display , "inline", "attribution is visible on the page" ); - plus(); - clearInterval( interval ); - } - }, 2000); - - interval2 = setInterval( function() { - if( popped.currentTime() > 3 && popped.currentTime() < 10 ) { - equals (attributiondiv.children[1].style.display , "inline", "second attribution is visible on the page" ); - plus(); - clearInterval( interval2 ); - } - }, 3000); - - interval3 = setInterval( function() { - if( popped.currentTime() > 10) { - equals (attributiondiv.children[1].style.display , "none", "second attribution is no longer visible on the page" ); - plus(); - equals (attributiondiv.children[0].style.display , "none", "first attribution is no longer visible on the page" ); - plus(); - clearInterval( interval3 ); - } - }, 11000); + popped.exec( 11, function() { + equals (attributiondiv.children[1].style.display , "none", "second attribution is no longer visible on the page" ); + plus(); + equals (attributiondiv.children[0].style.display , "none", "first attribution is no longer visible on the page" ); + plus(); + }); + popped.play(); + });