spec/integ/matrix-client-crypto.spec.js
function expectBobSendMessageRequest() {
    return expectSendMessageRequest(bobTestClient.httpBackend).then(function(content) {
        bobMessages.push(content);
        const aliKeyId = "curve25519:" + aliDeviceId;
        const aliDeviceCurve25519Key = aliTestClient.deviceKeys.keys[aliKeyId];
        expect(utils.keys(content.ciphertext)).toEqual([aliDeviceCurve25519Key]);
        const ciphertext = content.ciphertext[aliDeviceCurve25519Key];
        expect(ciphertext).toBeTruthy();
        return ciphertext;
    });
}
function expectBobSendMessageRequest() {
    return expectSendMessageRequest(bobTestClient.httpBackend).then(function(content) {
        bobMessages.push(content);
        const aliKeyId = "curve25519:" + aliDeviceId;
        const aliDeviceCurve25519Key = aliTestClient.deviceKeys.keys[aliKeyId];
        expect(utils.keys(content.ciphertext)).toEqual([aliDeviceCurve25519Key]);
        const ciphertext = content.ciphertext[aliDeviceCurve25519Key];
        expect(ciphertext).toBeTruthy();
        return ciphertext;
    });
}
function expectBobSendMessageRequest ( ) { return expectSendMessageRequest ( bobTestClient . httpBackend ) . then ( function ( content ) { bobMessages . push ( content ) ; const aliKeyId = "curve25519:" + aliDeviceId ; const aliDeviceCurve25519Key = aliTestClient . deviceKeys . keys [ aliKeyId ] ; expect ( utils . keys ( content . ciphertext ) ) . toEqual ( [ aliDeviceCurve25519Key ] ) ; const ciphertext = content . ciphertext [ aliDeviceCurve25519Key ] ; expect ( ciphertext ) . toBeTruthy ( ) ; return ciphertext ; } ) ; }
Set an expectation that Bob will send a message, and flush the request

@return {promise} which resolves to the ciphertext for Bob's device.
Set an expectation that Bob will send a message and flush the request