spec/integ/matrix-client-event-timeline.spec.js
function startClient(httpBackend, client) {
    httpBackend.when("GET", "/pushrules").respond(200, {});
    httpBackend.when("POST", "/filter").respond(200, { filter_id: "fid" });
    httpBackend.when("GET", "/sync").respond(200, INITIAL_SYNC_DATA);

    client.startClient();

    // set up a promise which will resolve once the client is initialised
    const deferred = Promise.defer();
    client.on("sync", function(state) {
        console.log("sync", state);
        if (state != "SYNCING") {
            return;
        }
        deferred.resolve();
    });

    return Promise.all([
        httpBackend.flushAllExpected(),
        deferred.promise,
    ]);
}
function startClient(httpBackend, client) {
    httpBackend.when("GET", "/pushrules").respond(200, {});
    httpBackend.when("POST", "/filter").respond(200, { filter_id: "fid" });
    httpBackend.when("GET", "/sync").respond(200, INITIAL_SYNC_DATA);

    client.startClient();

    // set up a promise which will resolve once the client is initialised
    const deferred = Promise.defer();
    client.on("sync", function(state) {
        console.log("sync", state);
        if (state != "SYNCING") {
            return;
        }
        deferred.resolve();
    });

    return Promise.all([
        httpBackend.flushAllExpected(),
        deferred.promise,
    ]);
}
function startClient ( httpBackend , client ) { httpBackend . when ( "GET" , "/pushrules" ) . respond ( 200 , { } ) ; httpBackend . when ( "POST" , "/filter" ) . respond ( 200 , { filter_id : "fid" } ) ; httpBackend . when ( "GET" , "/sync" ) . respond ( 200 , INITIAL_SYNC_DATA ) ; client . startClient ( ) ; // set up a promise which will resolve once the client is initialised const deferred = Promise . defer ( ) ; client . on ( "sync" , function ( state ) { console . log ( "sync" , state ) ; if ( state != "SYNCING" ) { return ; } deferred . resolve ( ) ; } ) ; return Promise . all ( [ httpBackend . flushAllExpected ( ) , deferred . promise , ] ) ; }
start the client, and wait for it to initialise
start the client and wait for it to initialise