Permalink
Browse files

Add a failing test for Collection.create not running callbacks

  • Loading branch information...
1 parent 1598801 commit 0f118ecb6e7b9021de49fcceadd5144b4996b277 @ptn ptn committed Apr 21, 2011
Showing with 16 additions and 0 deletions.
  1. +16 −0 test/collection.js
View
@@ -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() {

0 comments on commit 0f118ec

Please sign in to comment.