[Pkg-javascript-commits] [backbone] 05/23: add helper method to cleanup isNew test

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 17:00:43 UTC 2014


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

js pushed a commit to tag 0.5.1
in repository backbone.

commit 12e9d95b452852f7386cf401c9017737951092d0
Author: Matt Smith <matthewgarysmith at gmail.com>
Date:   Thu Mar 3 17:40:26 2011 -0500

    add helper method to cleanup isNew test
---
 test/model.js | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/test/model.js b/test/model.js
index 1fc5987..43de581 100644
--- a/test/model.js
+++ b/test/model.js
@@ -12,6 +12,10 @@ $(document).ready(function() {
     lastRequest = _.toArray(arguments);
   };
 
+  var model_with = function(attributes){
+    return new Backbone.Model(attributes);
+  }
+
   var attrs = {
     id     : '1-the-tempest',
     title  : "The Tempest",
@@ -92,12 +96,9 @@ $(document).ready(function() {
   });
 
   test("Model: isNew", function() {
-    a = new Backbone.Model({ });
-    ok(a.isNew(), "is true when there is no id");
-    a = new Backbone.Model({ 'id': 2 });
-    ok(!a.isNew(), "is false for a positive integer");
-    a = new Backbone.Model({ 'id': -5 });
-    ok(!a.isNew(), "is false for a negative integer");
+    ok( model_with({          }).isNew(), "is true when there is no id");
+    ok(!model_with({ 'id': 2  }).isNew(), "is false for a positive integer");
+    ok(!model_with({ 'id': -5 }).isNew(), "is false for a negative integer");
   });
 
   test("Model: get", function() {

-- 
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