[Pkg-javascript-commits] [backbone] 14/101: more tests
Jonas Smedegaard
js at moszumanska.debian.org
Sat May 3 16:58:24 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag 0.1.0
in repository backbone.
commit 21b66380dd237632cad2ea5ea5d5b8a1bfbc8f79
Author: Joe Germuska <joe at germuska.com>
Date: Sat Oct 2 16:19:57 2010 -0500
more tests
---
test/model.js | 36 +++++++++++++++++++++++++++++++++---
1 file changed, 33 insertions(+), 3 deletions(-)
diff --git a/test/model.js b/test/model.js
index 7075a51..a836bc9 100644
--- a/test/model.js
+++ b/test/model.js
@@ -6,9 +6,39 @@ $(document).ready(function() {
attrs = { 'foo': 1, 'bar': 2, 'baz': 3};
a = new Backbone.Model(attrs);
b = a.clone();
- equals(b.foo,a.foo,"Foo should be the same on the clone.");
- equals(b.bar,a.bar,"Bar should be the same on the clone.");
- equals(b.baz,a.baz,"Baz should be the same on the clone.");
+ equals(a.get('foo'),1);
+ equals(a.get('bar'),2);
+ equals(a.get('baz'),3);
+ equals(b.get('foo'),a.get('foo'),"Foo should be the same on the clone.");
+ equals(b.get('bar'),a.get('bar'),"Bar should be the same on the clone.");
+ equals(b.get('baz'),a.get('baz'),"Baz should be the same on the clone.");
+ });
+
+ test("model: isEqual", function() {
+ attrs = { 'foo': 1, 'bar': 2, 'baz': 3};
+ a = new Backbone.Model(attrs);
+ b = new Backbone.Model(attrs);
+ ok(a.isEqual(b),"a should equal b");
+ c = new Backbone.Model({ 'foo': 1, 'bar': 2, 'baz': 3, 'qux': 4});
+ ok(!a.isEqual(c),"a should not equal c");
+
+ })
+
+ test("model: isNew", function() {
+ attrs = { 'foo': 1, 'bar': 2, 'baz': 3};
+ a = new Backbone.Model(attrs);
+ ok(a.isNew());
+ })
+
+ test("model: set", function() {
+ attrs = { 'foo': 1, 'bar': 2, 'baz': 3};
+ a = new Backbone.Model(attrs);
+ var changeCount = 0;
+ a.bind("change", function() { changeCount += 1});
+ a.set({'foo': 2});
+ ok(a.get('foo')==2, "Foo should have changed.");
+ ok(changeCount == 1, "Change count should have incremented.");
+
});
});
\ No newline at end of file
--
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