uris77
11/20/2012 - 9:29 PM

Qunit example

Qunit example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:tal="http://xml.zope.org/namespaces/tal">
<head>
  <title>The Pyramid Web Application Development Framework</title>
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
  <meta name="keywords" content="python web application" />
  <meta name="description" content="pyramid web application" />
  <link rel="shortcut icon" href="${request.static_url('qunittest:static/favicon.ico')}" />
  <link rel="stylesheet" href="/static/js/tests/lib/qunit.css" type="text/css" media="screen">
  <!--[if lte IE 6]>
  <link rel="stylesheet" href="${request.static_url('qunittest:static/ie6.css')}" type="text/css" media="screen" charset="utf-8" />
  <![endif]-->
  <script type="text/javascript" src="/static/js/tests/lib/qunit.js"></script>
  <script type="text/javascript" src="/static/js/tests/lib/jquery.min.js"></script>
  <script type="text/javascript" src="/static/js/tests/lib/coffee-script.js"></script>
  <script type="text/coffeescript">
    $ ->
      scriptsToTest = ["http://localhost:6543/static/js/Calculator.coffee"]
      tests = ["http://localhost:6543/static/js/tests/Calculator_test.coffee"]
      loadCoffeeScript = (files) ->
        $head = $ "head"
        console.log $head
        load = (file) ->
          console.log "loading file #{file}"
          $.get file, (content) ->
            console.log "content: "
            console.log content
            compiled = CoffeeScript.compile content, {bare: on}
            console.log "compiled: "
            console.log compiled
            $("<script />").attr("type", "text/javascript").html(compiled).appendTo $head
        load file for file in files

      loadCoffeeScript scriptsToTest
      loadCoffeeScript tests
  </script>
</head>
<body>
  <h1 id="qunit-header">QUnit Tests</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">
</body>
</html>