You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
fix tests
This commit is contained in:
@@ -484,8 +484,9 @@ describe("megolm", function() {
|
|||||||
return aliceTestClient.flushSync().then(() => {
|
return aliceTestClient.flushSync().then(() => {
|
||||||
return aliceTestClient.flushSync();
|
return aliceTestClient.flushSync();
|
||||||
});
|
});
|
||||||
}).then(function() {
|
}).then(async function() {
|
||||||
const room = aliceTestClient.client.getRoom(ROOM_ID);
|
const room = aliceTestClient.client.getRoom(ROOM_ID);
|
||||||
|
await room.decryptCriticalEvents();
|
||||||
const event = room.getLiveTimeline().getEvents()[0];
|
const event = room.getLiveTimeline().getEvents()[0];
|
||||||
expect(event.getContent().body).toEqual('42');
|
expect(event.getContent().body).toEqual('42');
|
||||||
});
|
});
|
||||||
@@ -698,7 +699,7 @@ describe("megolm", function() {
|
|||||||
|
|
||||||
// the crypto stuff can take a while, so give the requests a whole second.
|
// the crypto stuff can take a while, so give the requests a whole second.
|
||||||
aliceTestClient.httpBackend.flushAllExpected({
|
aliceTestClient.httpBackend.flushAllExpected({
|
||||||
timeout: 1000,
|
timeout: 10000,
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
@@ -933,8 +934,9 @@ describe("megolm", function() {
|
|||||||
|
|
||||||
aliceTestClient.httpBackend.when("GET", "/sync").respond(200, syncResponse);
|
aliceTestClient.httpBackend.when("GET", "/sync").respond(200, syncResponse);
|
||||||
return aliceTestClient.flushSync();
|
return aliceTestClient.flushSync();
|
||||||
}).then(function() {
|
}).then(async function() {
|
||||||
const room = aliceTestClient.client.getRoom(ROOM_ID);
|
const room = aliceTestClient.client.getRoom(ROOM_ID);
|
||||||
|
await room.decryptCriticalEvents();
|
||||||
const event = room.getLiveTimeline().getEvents()[0];
|
const event = room.getLiveTimeline().getEvents()[0];
|
||||||
expect(event.getContent().body).toEqual('42');
|
expect(event.getContent().body).toEqual('42');
|
||||||
|
|
||||||
|
|||||||
@@ -212,10 +212,9 @@ MockStorageApi.prototype = {
|
|||||||
* @returns {Promise} promise which resolves (to `event`) when the event has been decrypted
|
* @returns {Promise} promise which resolves (to `event`) when the event has been decrypted
|
||||||
*/
|
*/
|
||||||
export function awaitDecryption(event) {
|
export function awaitDecryption(event) {
|
||||||
if (!event.isBeingDecrypted()) {
|
if (event.getClearContent() !== null) {
|
||||||
return Promise.resolve(event);
|
return event;
|
||||||
}
|
} else {
|
||||||
|
|
||||||
logger.log(`${Date.now()} event ${event.getId()} is being decrypted; waiting`);
|
logger.log(`${Date.now()} event ${event.getId()} is being decrypted; waiting`);
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@@ -225,6 +224,7 @@ export function awaitDecryption(event) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export function HttpResponse(
|
export function HttpResponse(
|
||||||
|
|||||||
@@ -5556,7 +5556,7 @@ function _resolve(callback, resolve, res) {
|
|||||||
|
|
||||||
function _PojoToMatrixEventMapper(client, options = {}) {
|
function _PojoToMatrixEventMapper(client, options = {}) {
|
||||||
const preventReEmit = Boolean(options.preventReEmit);
|
const preventReEmit = Boolean(options.preventReEmit);
|
||||||
const decrypt = options.decrypt === true;
|
const decrypt = options.decrypt !== false;
|
||||||
function mapper(plainOldJsObject) {
|
function mapper(plainOldJsObject) {
|
||||||
const event = new MatrixEvent(plainOldJsObject);
|
const event = new MatrixEvent(plainOldJsObject);
|
||||||
if (event.isEncrypted()) {
|
if (event.isEncrypted()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user