Lines Matching full:add

72     collection.add({id: 2});
100 collection2.add(model.attributes);
127 collection.add([
150 QUnit.test('add', function(assert) {
155 otherCol.add(e);
156 otherCol.on('add', function() {
159 col.on('add', function(model, collection, options){
163 col.add(e, {amazing: true});
176 atCol.add(e, {at: 1});
183 coll.on('add', function(){
186 coll.add([undefined, f, g]);
189 coll.add(new Array(4));
194 QUnit.test('add multiple models', function(assert) {
197 collection.add([{at: 2}, {at: 3}, {at: 4}, {at: 5}, {at: 6}, {at: 7}, {at: 8}], {at: 2});
203 QUnit.test('add; at should have preference over comparator', function(assert) {
212 collection.add(new Backbone.Model({id: 1}), {at: 1});
217 QUnit.test('add; at should add to the end if the index is out of bounds', function(assert) {
220 collection.add(new Backbone.Model({id: 1}), {at: 5});
225 QUnit.test("can't add model to collection twice", function(assert) {
230 QUnit.test("can't add different model with same id to collection twice", function(assert) {
234 collection.add({id: 101});
241 collection.add([{id: 1, name: 'Moe'}, {id: 2, name: 'Curly'}, {id: 3, name: 'Larry'}]);
242 collection.add({id: 1, name: 'Moses'});
244 collection.add({id: 1, name: 'Moses'}, {merge: true});
246 collection.add({id: 1, name: 'Tim'}, {merge: true, silent: true});
250 QUnit.test('add model to multiple collections', function(assert) {
254 m.on('add', function(model, collection) {
264 col1.on('add', function(model, collection) {
269 col2.on('add', function(model, collection) {
273 col1.add(m);
275 col2.add(m);
279 QUnit.test('add model with parse', function(assert) {
290 collection.add({value: 1}, {parse: true});
294 QUnit.test('add with parse and merge', function(assert) {
302 collection.add({id: 1});
303 collection.add({model: {id: 1, name: 'Alf'}}, {parse: true, merge: true});
307 QUnit.test('add model to collection with sort()-style comparator', function(assert) {
316 collection.add(tom);
317 collection.add(rob);
318 collection.add(tim);
333 collection.add([{id: 1}, {id: 2}, {id: 3}]);
370 QUnit.test('add and remove return values', function(assert) {
380 var list = collection.add([{id: 2}, {id: 4}], {validate: true});
386 list = collection.add([{id: 3}, {id: 6}], {validate: true});
391 var result = collection.add({id: 6});
864 QUnit.test('add does not alter arguments', function(assert) {
868 new Backbone.Collection().add(models);
913 collection.add([{id: 1}, {id: 2}, {id: 3}, {id: 4}, {id: 5}, {id: 6}], {validate: true});
925 collection.add([model, {id: 2}], {validate: true});
937 collection.add([model, model]);
939 collection.add([{id: 1}, {id: 1}]);
1051 collection.on('add', function(){ assert.ok(true); });
1055 QUnit.test('#1448 - add sorts collection after merge.', function(assert) {
1062 collection.add({id: 1, x: 3}, {merge: true});
1087 collection.on('add', function() {
1090 collection.add({}, {at: 0});
1093 QUnit.test('#1638 - `sort` during `add` triggers correctly.', function(assert) {
1097 collection.on('add', function(model) {
1102 collection.add([{id: 1, x: 1}, {id: 2, x: 2}]);
1121 QUnit.test("`sort` shouldn't always fire on `add`", function(assert) {
1127 collection.add([]);
1128 collection.add({id: 1});
1129 collection.add([{id: 2}, {id: 3}]);
1130 collection.add({id: 4});
1195 // Test add/change/remove events
1196 collection.on('add', function(model) {
1210 // add: false doesn't add any models
1211 collection.set([m1, m2, m3], {add: false});
1218 // add: false, remove: false only merges existing models
1219 collection.set([m1, {id: 2, a: 0}, m3, {id: 4}], {add: false, remove: false});
1223 // default options add/remove/merge as appropriate
1351 collection.set([three, two, one, {id: 4}], {add: false});
1377 collection.set([{_id: 1, a: 1}], {add: false});
1387 new Collection().add({id: 1}, {sort: false});
1442 QUnit.test('`add` only `sort`s when necessary', function(assert) {
1448 collection.add({id: 4}); // do sort, new model
1449 collection.add({id: 1, a: 1}, {merge: true}); // do sort, comparator change
1450 collection.add({id: 1, b: 1}, {merge: true}); // don't sort, no comparator change
1451 collection.add({id: 1, a: 1}, {merge: true}); // don't sort, no comparator change
1452 collection.add(collection.models); // don't sort, nothing new
1453 collection.add(collection.models, {merge: true}); // don't sort
1456 QUnit.test('`add` only `sort`s when necessary with comparator function', function(assert) {
1464 collection.add({id: 4}); // do sort, new model
1465 collection.add({id: 1, a: 1}, {merge: true}); // do sort, model change
1466 collection.add({id: 1, b: 1}, {merge: true}); // do sort, model change
1467 collection.add({id: 1, a: 1}, {merge: true}); // don't sort, no model change
1468 collection.add(collection.models); // don't sort, nothing new
1469 collection.add(collection.models, {merge: true}); // don't sort
1502 QUnit.test('`add` overrides `set` flags', function(assert) {
1504 collection.once('add', function(model, coll, options) {
1505 coll.add({id: 2}, options);
1608 var calls = {add: 0, remove: 0}; property in AnonymousFunctionf8dce19ebe00.calls
1614 calls.add++;
1631 var model = collection.add({id: 1});
1634 assert.equal(calls.add, 1);
1638 QUnit.test('Do not allow duplicate models to be `add`ed or `set`', function(assert) {
1641 collection.add([{id: 1}, {id: 1}]);
1650 QUnit.test('#3020: #set with {add: false} should not throw.', function(assert) {
1653 collection.set([{id: 1}], {add: false});
1756 c2.add(m);
1764 collection.on('add', function(model, coll, options) {
1767 collection.add([{val: 1}, {val: 2}, {val: 3}], {at: 1});
1768 collection.add({val: 5}, {at: 10});
1774 collection.on('add', function(model, coll, options) {
1777 collection.add([{at: 1}, {at: 2}]);
1816 QUnit.test('add supports negative indexes', function(assert) {
1819 collection.add([{id: 2}, {id: 3}], {at: -1});
1820 collection.add([{id: 2.5}], {at: -2});
1821 collection.add([{id: 0.5}], {at: -6});
1828 collection.add([{id: 3}], {at: '1'});
1836 collection.add([{id: 1}, {id: 2}, {id: 3}]);