mirror of
https://github.com/jashkenas/backbone.git
synced 2026-01-22 13:28:22 -05:00
some more tests
This commit is contained in:
@@ -1,28 +1,21 @@
|
||||
$(document).ready(function() {
|
||||
|
||||
module("Bindable");
|
||||
module("Backbone bindable");
|
||||
|
||||
test("bind and trigger", function() {
|
||||
var obj = { counter: 0 }
|
||||
_.extend(obj,Backbone.Bindable);
|
||||
obj.bind('foo',function() { obj.counter += 1; });
|
||||
obj.trigger('foo');
|
||||
equals(obj.counter,1,'counter should be incremented.');
|
||||
});
|
||||
|
||||
test("repeated trigger", function() {
|
||||
test("bindable: bind and trigger", function() {
|
||||
var obj = { counter: 0 }
|
||||
_.extend(obj,Backbone.Bindable);
|
||||
obj.bind('foo',function() { obj.counter += 1; });
|
||||
obj.trigger('foo');
|
||||
equals(obj.counter,1,'counter should be incremented.');
|
||||
obj.trigger('foo');
|
||||
obj.trigger('foo');
|
||||
obj.trigger('foo');
|
||||
obj.trigger('foo');
|
||||
equals(obj.counter,5,'counter should be incremented five times.');
|
||||
});
|
||||
|
||||
test("bind, then unbind all functions", function() {
|
||||
|
||||
test("bindable: bind, then unbind all functions", function() {
|
||||
var obj = { counter: 0 }
|
||||
_.extend(obj,Backbone.Bindable);
|
||||
var callback = function() { obj.counter += 1; }
|
||||
@@ -32,8 +25,8 @@ $(document).ready(function() {
|
||||
obj.trigger('foo');
|
||||
equals(obj.counter,1,'counter should have only been incremented once.')
|
||||
});
|
||||
|
||||
test("bind two callbacks, unbind only one", function() {
|
||||
|
||||
test("bindable: bind two callbacks, unbind only one", function() {
|
||||
var obj = { counterA: 0, counterB: 0 }
|
||||
_.extend(obj,Backbone.Bindable);
|
||||
var callback = function() { obj.counterA += 1; };
|
||||
|
||||
0
test/collection.js
Normal file
0
test/collection.js
Normal file
14
test/model.js
Normal file
14
test/model.js
Normal file
@@ -0,0 +1,14 @@
|
||||
$(document).ready(function() {
|
||||
|
||||
module("Backbone model");
|
||||
|
||||
test("model: clone", 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.");
|
||||
});
|
||||
|
||||
});
|
||||
@@ -9,6 +9,9 @@
|
||||
<script type="text/javascript" src="../backbone.js"></script>
|
||||
|
||||
<script type="text/javascript" src="bindable.js"></script>
|
||||
<script type="text/javascript" src="model.js"></script>
|
||||
<script type="text/javascript" src="collection.js"></script>
|
||||
<script type="text/javascript" src="view.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">Backbone Test Suite</h1>
|
||||
|
||||
0
test/view.js
Normal file
0
test/view.js
Normal file
Reference in New Issue
Block a user