Permalink
Browse files

Added a view extension for base.

  • Loading branch information...
1 parent 8f8ee92 commit 2e70de5f46615e691d6f747d2d3c96e8eaccb03e @ratnikov ratnikov committed Feb 25, 2009
Showing with 60 additions and 0 deletions.
  1. +6 −0 src/view.js
  2. +27 −0 test/view_test.html
  3. +27 −0 test/view_test.js
View
@@ -0,0 +1,6 @@
+
+AjaxResource.View = function() { };
+
+AjaxResource.View.prototype.default_view = function() {
+ return this.resource_name() + ' (id: '+this.id()+')';
+};
View
@@ -0,0 +1,27 @@
+<html>
+ <head>
+ <script src="../lib/jquery-1.3.1.js"></script>
+
+ <script src="../src/init.js"></script>
+ <script src="../src/util.js"></script>
+
+ <script src="../src/attribute_mod.js"></script>
+ <script src="../src/routing.js"></script>
+ <script src="../src/base.js"></script>
+
+ <script src="../lib/testrunner.js"></script>
+ <link rel="stylesheet" href="../lib/testsuite.css" />
+ </head>
+ <body>
+ <script src="../src/view.js"></script>
+ <script src="view_test.js"></script>
+
+ <h1>AjaxResource.View test</h1>
+ <h2 id="banner"></h2>
+ <h2 id="userAgent"></h2>
+
+ <ol id="tests"></ol>
+
+ <div id="main"></div>
+ </body>
+</html>
View
@@ -0,0 +1,27 @@
+
+jQuery(document).ready(function() {
+ test("Truthitest", function() {
+ ok(true);
+ });
+
+ module("#default_view", {
+ setup : function() {
+ model = new AjaxResource.View();
+ model.resource_name = function() {
+ return 'funky_foo';
+ };
+
+ model.id = function() {
+ return this._id;
+ };
+ }
+ });
+
+ test("Should return in format: '{resource_name} (id: {id})'", function() {
+ model._id = '5';
+ equals(model.default_view(), 'funky_foo (id: 5)');
+
+ model._id = null;
+ equals(model.default_view(), 'funky_foo (id: null)');
+ });
+});

0 comments on commit 2e70de5

Please sign in to comment.