From: David Humphrey Date: Sun, 13 Feb 2011 01:36:58 +0000 (-0500) Subject: Adding initial mustache unit tests. X-Git-Tag: v0.4~50^2~8 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=1684003fdfcb151ab1248cc0d436eedcda9551e6;p=popcorn-js.git Adding initial mustache unit tests. --- diff --git a/plugins/mustache/popcorn.mustache.unit.html b/plugins/mustache/popcorn.mustache.unit.html new file mode 100644 index 0000000..18a329f --- /dev/null +++ b/plugins/mustache/popcorn.mustache.unit.html @@ -0,0 +1,46 @@ + + + + Popcorn API + + + + + + + + + + + +

Popcorn Mustache Plugin

+

+
+

+
    +
    + + +
    + + diff --git a/plugins/mustache/popcorn.mustache.unit.js b/plugins/mustache/popcorn.mustache.unit.js new file mode 100644 index 0000000..2696bff --- /dev/null +++ b/plugins/mustache/popcorn.mustache.unit.js @@ -0,0 +1,44 @@ +test("Popcorn Mustache Plugin", function () { + + var popped = Popcorn("#video"), + expects = 3, + count = 0, + interval, + mustacheDiv = document.getElementById('mustache-div'); + + expect( expects ); + + function plus() { + if ( ++count === expects) { + start(); + } + } + + stop(); + + ok('mustache' in popped, "mustache is a method of the popped instance"); + plus(); + + equals ( mustacheDiv.innerHTML, "", "initially, there is nothing inside the mustache-div" ); + plus(); + + popped.mustache({ + start: 1, // seconds + end: 3, // seconds + template: "

    {{heading}}

    ", + data: '{"heading": "mustache"}', + target: 'mustache-div', + static: true + } ); + + interval = setInterval( function() { + if( popped.currentTime() > 1 && popped.currentTime() < 3 ) { + ok( /

    mustache<\/h1>/.test( mustacheDiv.innerHTML ), "Mustache template rendered" ); + plus(); + clearInterval( interval ); + } + }, 500); + + popped.volume(0); + popped.play(); +});