Update vendors, minified builds, and rebuild docs.

Former-commit-id: 9be99ca3c78a1a35fd13138398c48ab4a4b35f11
This commit is contained in:
John-David Dalton
2013-01-12 20:02:16 -08:00
parent 2d202e90b7
commit e4cb7112cf
12 changed files with 222 additions and 170 deletions

View File

@@ -497,9 +497,21 @@ $(document).ready(function() {
[4, 0]);
});
test("sortedIndex", function () {
var model = new Backbone.Model({key: 2});
var collection = new (Backbone.Collection.extend({
comparator: 'key'
}))([model, {key: 1}]);
equal(collection.sortedIndex(model), 1);
equal(collection.sortedIndex(model, 'key'), 1);
equal(collection.sortedIndex(model, function (model) {
return model.get('key');
}), 1);
});
test("reset", 10, function() {
var resetCount = 0;
var models = col.models;
var models = col.models.slice();
col.on('reset', function() { resetCount += 1; });
col.reset([]);
equal(resetCount, 1);

View File

@@ -86,6 +86,20 @@ $(document).ready(function() {
b.trigger('change');
});
test("listenTo yourself", 1, function(){
var e = _.extend({}, Backbone.Events);
e.listenTo(e, "foo", function(){ ok(true); });
e.trigger("foo");
});
test("listenTo yourself cleans yourself up with stopListening", 1, function(){
var e = _.extend({}, Backbone.Events);
e.listenTo(e, "foo", function(){ ok(true); });
e.trigger("foo");
e.stopListening();
e.trigger("foo");
});
test("trigger all for each event", 3, function() {
var a, b, obj = { counter: 0 };
_.extend(obj, Backbone.Events);

View File

@@ -734,6 +734,13 @@ $(document).ready(function() {
model.save({x: 1}, {wait: true});
});
test("save turns on parse flag", function () {
var Model = Backbone.Model.extend({
sync: function(method, model, options) { ok(options.parse); }
});
new Model().save();
});
test("nested `set` during `'change:attr'`", 2, function() {
var events = [];
var model = new Backbone.Model();

View File

@@ -69,6 +69,7 @@ $(document).ready(function() {
"contacts": "contacts",
"contacts/new": "newContact",
"contacts/:id": "loadContact",
"route-event/:arg": "routeEvent",
"optional(/:item)": "optionalItem",
"named/optional/(y:z)": "namedOptional",
"splat/*args/end": "splat",
@@ -132,6 +133,9 @@ $(document).ready(function() {
namedOptional: function(z) {
this.z = z;
},
routeEvent: function(arg) {
}
});
@@ -516,4 +520,13 @@ $(document).ready(function() {
strictEqual(router.z, '123');
});
test("#2062 - Trigger 'route' event on router instance.", 2, function() {
router.on('route', function(name, args) {
strictEqual(name, 'routeEvent');
deepEqual(args, ['x']);
});
location.replace('http://example.com#route-event/x');
Backbone.history.checkUrl();
});
});