Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a failing test for Collection.create not running callbacks

  • Loading branch information...
commit 0f118ecb6e7b9021de49fcceadd5144b4996b277 1 parent 1598801
@ptn ptn authored
Showing with 16 additions and 0 deletions.
  1. +16 −0 test/collection.js
View
16 test/collection.js
@@ -233,6 +233,22 @@ $(document).ready(function() {
equals(col.create({"foo":"bar"}),false);
});
+ test("Collection: a failing create runs the error callback", function() {
+ var ValidatingModel = Backbone.Model.extend({
+ validate: function(attrs) {
+ return "fail";
+ }
+ });
+ var ValidatingCollection = Backbone.Collection.extend({
+ model: ValidatingModel
+ });
+ var flag = false;
+ var callback = function(model, error) { flag = true; };
+ var col = new ValidatingCollection();
+ col.create({"foo":"bar"}, { error: callback });
+ equals(flag, true);
+ });
+
test("collection: initialize", function() {
var Collection = Backbone.Collection.extend({
initialize: function() {
Please sign in to comment.
Something went wrong with that request. Please try again.