[Pkg-javascript-commits] [backbone] 08/19: Adding basic tests for initialize.

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 16:58:37 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 0.1.1
in repository backbone.

commit 091e266077fec2092942a8936173db916a82f1a2
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date:   Wed Oct 13 17:33:20 2010 -0400

    Adding basic tests for initialize.
---
 test/collection.js | 10 ++++++++++
 test/model.js      | 10 ++++++++++
 test/view.js       | 10 ++++++++++
 3 files changed, 30 insertions(+)

diff --git a/test/collection.js b/test/collection.js
index a326979..1499b09 100644
--- a/test/collection.js
+++ b/test/collection.js
@@ -86,6 +86,16 @@ $(document).ready(function() {
     equals(model.collection, col);
   });
 
+  test("collection: initialize", function() {
+    var Collection = Backbone.Collection.extend({
+      initialize: function() {
+        this.one = 1;
+      }
+    });
+    var coll = new Collection;
+    equals(coll.one, 1);
+  });
+
   test("collections: Underscore methods", function() {
     equals(col.map(function(model){ return model.get('label'); }).join(' '), 'd c b a');
     equals(col.any(function(model){ return model.id === 100; }), false);
diff --git a/test/model.js b/test/model.js
index 9d1e68d..f10e914 100644
--- a/test/model.js
+++ b/test/model.js
@@ -26,6 +26,16 @@ $(document).ready(function() {
   var collection = new klass();
   collection.add(doc);
 
+  test("model: initialize", function() {
+    var Model = Backbone.Model.extend({
+      initialize: function() {
+        this.one = 1;
+      }
+    });
+    var model = new Model;
+    equals(model.one, 1);
+  });
+
   test("model: url", function() {
     equals(doc.url(), '/collection/1-the-tempest');
   });
diff --git a/test/view.js b/test/view.js
index 8c3bc85..e05b2bd 100644
--- a/test/view.js
+++ b/test/view.js
@@ -26,6 +26,16 @@ $(document).ready(function() {
     equals($(div).text(), 'one two three');
   });
 
+  test("view: initialize", function() {
+    var View = Backbone.View.extend({
+      initialize: function() {
+        this.one = 1;
+      }
+    });
+    var view = new View;
+    equals(view.one, 1);
+  });
+
   test("view: handleEvents", function() {
     var counter = 0;
     view.el = document.body;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git



More information about the Pkg-javascript-commits mailing list