lib/livedata/SyncContext.spec.js
function loadCollection(collection, data) {
        return Q(collection.fetch()).then(function () {
            // delete all before running tests
            return Q.all(collection.models.slice().map(function (model) {
                return model.destroy();
            })).then(function () {
                chai_1.assert.equal(collection.models.length, 0, 'collection must be empty initially after destroy');
                return collection;
            });
        }).then(function (collection2) {
            // load sample data into fresh database
            chai_1.assert.equal(collection2, collection, 'same collection object');
            return Q.all(data.map(function (attrs) {
                return new TestModel(attrs, {
                    collection: collection2
                }).save();
            })).then(function () {
                chai_1.assert.equal(collection2.models.length, data.length, 'collection was updated by async events');
                return collection2;
            });
        });
    }
function loadCollection(collection, data) {
        return Q(collection.fetch()).then(function () {
            // delete all before running tests
            return Q.all(collection.models.slice().map(function (model) {
                return model.destroy();
            })).then(function () {
                chai_1.assert.equal(collection.models.length, 0, 'collection must be empty initially after destroy');
                return collection;
            });
        }).then(function (collection2) {
            // load sample data into fresh database
            chai_1.assert.equal(collection2, collection, 'same collection object');
            return Q.all(data.map(function (attrs) {
                return new TestModel(attrs, {
                    collection: collection2
                }).save();
            })).then(function () {
                chai_1.assert.equal(collection2.models.length, data.length, 'collection was updated by async events');
                return collection2;
            });
        });
    }
function loadCollection ( collection , data ) { return Q ( collection . fetch ( ) ) . then ( function ( ) { // delete all before running tests return Q . all ( collection . models . slice ( ) . map ( function ( model ) { return model . destroy ( ) ; } ) ) . then ( function ( ) { chai_1 . assert . equal ( collection . models . length , 0 , 'collection must be empty initially after destroy' ) ; return collection ; } ) ; } ) . then ( function ( collection2 ) { // load sample data into fresh database chai_1 . assert . equal ( collection2 , collection , 'same collection object' ) ; return Q . all ( data . map ( function ( attrs ) { return new TestModel ( attrs , { collection : collection2 } ) . save ( ) ; } ) ) . then ( function ( ) { chai_1 . assert . equal ( collection2 . models . length , data . length , 'collection was updated by async events' ) ; return collection2 ; } ) ; } ) ; }
loads data using collection, returns promise on collection, collection is empty afterwards
loads data using collection returns promise on collection collection is empty afterwards