adding test for falsy comparators (#1342)

This commit is contained in:
Sam Breed
2012-05-23 23:53:13 -06:00
parent 6d21c05b18
commit 98e01bbc4a
2 changed files with 14 additions and 1 deletions

View File

@@ -599,4 +599,17 @@ $(document).ready(function() {
ok(!collection.get('undefined'));
});
test("Collection: falsy comparator", function(){
var Col = Backbone.Collection.extend({
comparator: function(model){ return model.id; }
});
var col = new Col([{id: 2}, {id: 1}], {
comparator: false
});
var otherCol = new Col([{id: 2}, {id: 1}]);
raises(function(){ col.sort() });
equal(col.first().id, 2);
equal(otherCol.first().id, 1);
});
});