]> git.parisson.com Git - pdf.js.git/commitdiff
Create first unit test in Jasmine unit test framework.
authorKalervo Kujala <kkujala@com>
Sun, 13 Nov 2011 19:39:56 +0000 (21:39 +0200)
committerKalervo Kujala <kkujala@com>
Sun, 13 Nov 2011 19:39:56 +0000 (21:39 +0200)
To run the unit test open pdf.js/test/unit/unit_test.html in your browser.

This requires that https://github.com/pivotal/jasmine is cloned to the same
directory level as pdf.js.

test/unit/spec/obj_spec.js [new file with mode: 0644]
test/unit/unit_test.html [new file with mode: 0644]

diff --git a/test/unit/spec/obj_spec.js b/test/unit/spec/obj_spec.js
new file mode 100644 (file)
index 0000000..b79a21e
--- /dev/null
@@ -0,0 +1,16 @@
+/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
+
+'use strict';
+
+describe("obj", function() {
+
+  describe("Name", function() {
+    it("should retain the given name", function() {
+      var givenName = "My Name";
+      var name = new Name(givenName);
+      expect(name.name).toEqual(givenName);
+    });
+  });
+});
+
diff --git a/test/unit/unit_test.html b/test/unit/unit_test.html
new file mode 100644 (file)
index 0000000..cedd65c
--- /dev/null
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>pdf.js unit test</title>
+
+  <link rel="shortcut icon" type="image/png" href="../../../jasmine/images/jasmine_favicon.png">
+  <link rel="stylesheet" type="text/css" href="../../../jasmine/lib/jasmine-core/jasmine.css">
+
+  <script type="text/javascript" src="../../../jasmine/lib/jasmine-core/jasmine.js"></script>
+  <script type="text/javascript" src="../../../jasmine/lib/jasmine-core/jasmine-html.js"></script>
+
+  <!-- include spec files here... -->
+  <script type="text/javascript" src="spec/obj_spec.js"></script>
+
+  <!-- include source files here... -->
+  <script type="text/javascript" src="../../src/obj.js"></script>
+
+  <script type="text/javascript">
+    'use strict';
+
+    (function pdfJsUnitTest() {
+      var jasmineEnv = jasmine.getEnv();
+      jasmineEnv.updateInterval = 1000;
+
+      var trivialReporter = new jasmine.TrivialReporter();
+
+      jasmineEnv.addReporter(trivialReporter);
+
+      jasmineEnv.specFilter = function pdfJsUnitTestSpecFilter(spec) {
+        return trivialReporter.specFilter(spec);
+      };
+
+      var currentWindowOnload = window.onload;
+
+      window.onload = function pdfJsUnitTestOnload() {
+        if (currentWindowOnload) {
+          currentWindowOnload();
+        }
+        execJasmine();
+      };
+
+      function execJasmine() {
+        jasmineEnv.execute();
+      }
+    })();
+  </script>
+</head>
+<body>
+</body>
+</html>
+