Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added a view extension for base.

  • Loading branch information...
commit 2e70de5f46615e691d6f747d2d3c96e8eaccb03e 1 parent 8f8ee92
Dmitry Ratnikov authored February 25, 2009
6  src/view.js
... ...
@@ -0,0 +1,6 @@
  1
+
  2
+AjaxResource.View = function() { };
  3
+
  4
+AjaxResource.View.prototype.default_view = function() {
  5
+  return this.resource_name() + ' (id: '+this.id()+')';
  6
+};
27  test/view_test.html
... ...
@@ -0,0 +1,27 @@
  1
+<html>
  2
+  <head>
  3
+    <script src="../lib/jquery-1.3.1.js"></script>
  4
+
  5
+    <script src="../src/init.js"></script>
  6
+    <script src="../src/util.js"></script>
  7
+
  8
+    <script src="../src/attribute_mod.js"></script>
  9
+    <script src="../src/routing.js"></script>
  10
+    <script src="../src/base.js"></script>
  11
+
  12
+    <script src="../lib/testrunner.js"></script>
  13
+    <link rel="stylesheet" href="../lib/testsuite.css" />
  14
+  </head>
  15
+  <body>
  16
+    <script src="../src/view.js"></script>
  17
+    <script src="view_test.js"></script>
  18
+
  19
+    <h1>AjaxResource.View test</h1>
  20
+    <h2 id="banner"></h2>
  21
+    <h2 id="userAgent"></h2>
  22
+
  23
+    <ol id="tests"></ol>
  24
+
  25
+    <div id="main"></div>
  26
+  </body>
  27
+</html>
27  test/view_test.js
... ...
@@ -0,0 +1,27 @@
  1
+
  2
+jQuery(document).ready(function() {
  3
+  test("Truthitest", function() {
  4
+    ok(true);
  5
+  });
  6
+
  7
+  module("#default_view", {
  8
+    setup : function() {
  9
+      model = new AjaxResource.View();
  10
+      model.resource_name = function() {
  11
+	return 'funky_foo';
  12
+      };
  13
+
  14
+      model.id = function() {
  15
+	return this._id;
  16
+      };
  17
+    }
  18
+  });
  19
+
  20
+  test("Should return in format: '{resource_name} (id: {id})'", function() {
  21
+    model._id = '5';
  22
+    equals(model.default_view(), 'funky_foo (id: 5)');
  23
+
  24
+    model._id = null;
  25
+    equals(model.default_view(), 'funky_foo (id: null)');
  26
+  });
  27
+});

0 notes on commit 2e70de5

Please sign in to comment.
Something went wrong with that request. Please try again.