Last active
August 29, 2015 14:16
-
-
Save jameshartig/b954f60abe3b85bac7c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test('Do not allow duplicate models (with nonstandard id) to be `add`ed or `set`', function() { | |
var Stooge = Backbone.Model.extend({ | |
parse: function(a) { | |
var attrs = {}; | |
attrs._id = a.__id; | |
return attrs; | |
} | |
}); | |
Stooge.prototype.idAttribute = '_id'; | |
var StoogeCollection = Backbone.Collection.extend({model: Stooge}), | |
c = new StoogeCollection(); | |
c.add([{__id: 1}, {__id: 1}]); | |
equal(c.length, 1); | |
equal(c.models.length, 1); | |
c.set([{__id: 1}, {__id: 1}]); | |
equal(c.length, 1); | |
equal(c.models.length, 1); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment