From 1684003fdfcb151ab1248cc0d436eedcda9551e6 Mon Sep 17 00:00:00 2001 From: David Humphrey Date: Sat, 12 Feb 2011 20:36:58 -0500 Subject: [PATCH] Adding initial mustache unit tests. --- plugins/mustache/popcorn.mustache.unit.html | 46 +++++++++++++++++++++ plugins/mustache/popcorn.mustache.unit.js | 44 ++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 plugins/mustache/popcorn.mustache.unit.html create mode 100644 plugins/mustache/popcorn.mustache.unit.js 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(); +}); -- 2.43.0