]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
Adding initial mustache unit tests.
authorDavid Humphrey <david.humphrey@senecac.on.ca>
Sun, 13 Feb 2011 01:36:58 +0000 (20:36 -0500)
committerDavid Humphrey <david.humphrey@senecac.on.ca>
Sun, 13 Feb 2011 01:36:58 +0000 (20:36 -0500)
plugins/mustache/popcorn.mustache.unit.html [new file with mode: 0644]
plugins/mustache/popcorn.mustache.unit.js [new file with mode: 0644]

diff --git a/plugins/mustache/popcorn.mustache.unit.html b/plugins/mustache/popcorn.mustache.unit.html
new file mode 100644 (file)
index 0000000..18a329f
--- /dev/null
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Popcorn API</title>
+  <link rel="stylesheet" href="../../test/qunit/qunit.css" type="text/css" media="screen">
+  <script src="../../test/qunit/qunit.js"></script>
+  <!--
+    do not move - this must be called immediately prior to
+    popcorn-api-draft.js
+  -->
+
+  <script src="../../popcorn.js"></script>
+  <script src="../../test/jquery.js"></script>
+  <script src="popcorn.mustache.js"></script>
+  <script src="popcorn.mustache.unit.js"></script>
+</head>
+<body>
+
+  <h1 id="qunit-header">Popcorn Mustache Plugin</h1>
+  <h2 id="qunit-banner"></h2>
+  <div id="qunit-testrunner-toolbar"></div>
+  <h2 id="qunit-userAgent"></h2>
+  <ol id="qunit-tests"></ol>
+  <div id="qunit-fixture">  </div>
+
+  <video id='video'
+    autobuffer
+    preload="auto"
+    controls
+    width= '250px'
+    poster="../../test/poster.png">
+
+    <source id='mp4'
+      src="../../test/trailer.mp4"
+      type='video/mp4; codecs="avc1, mp4a"'>
+
+    <source id='ogv'
+      src="../../test/trailer.ogv"
+      type='video/ogg; codecs="theora, vorbis"'>
+
+    <p>Your user agent does not support the HTML5 Video element.</p>
+
+  </video>
+  <div id="mustache-div"></div>
+</body>
+</html>
diff --git a/plugins/mustache/popcorn.mustache.unit.js b/plugins/mustache/popcorn.mustache.unit.js
new file mode 100644 (file)
index 0000000..2696bff
--- /dev/null
@@ -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: "<h1>{{heading}}</h1>",
+    data: '{"heading": "mustache"}',
+    target: 'mustache-div',
+    static: true
+  } );
+
+  interval = setInterval( function() {
+    if( popped.currentTime() > 1 && popped.currentTime() < 3 ) {
+      ok( /<h1>mustache<\/h1>/.test( mustacheDiv.innerHTML ), "Mustache template rendered" );
+      plus();
+      clearInterval( interval );
+    }
+  }, 500);
+
+  popped.volume(0);
+  popped.play();
+});