You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2026-01-03 23:22:30 +03:00
Deflake megolm unit test
Waiting for 1ms isn't actually good enough. wait for the actual thing we are actually waiting for.
This commit is contained in:
@@ -124,19 +124,23 @@ describe("MegolmDecryption", function() {
|
||||
// set up some pre-conditions for the share call
|
||||
const deviceInfo = {};
|
||||
mockCrypto.getStoredDevice.andReturn(deviceInfo);
|
||||
mockOlmLib.ensureOlmSessionsForDevices.andReturn(
|
||||
Promise.resolve({'@alice:foo': {'alidevice': {
|
||||
sessionId: 'alisession',
|
||||
}}}),
|
||||
);
|
||||
mockBaseApis.sendToDevice = expect.createSpy();
|
||||
|
||||
const awaitEnsureSessions = new Promise((res, rej) => {
|
||||
mockOlmLib.ensureOlmSessionsForDevices.andCall(() => {
|
||||
res();
|
||||
return Promise.resolve({'@alice:foo': {'alidevice': {
|
||||
sessionId: 'alisession',
|
||||
}}});
|
||||
});
|
||||
});
|
||||
|
||||
mockBaseApis.sendToDevice = expect.createSpy();
|
||||
|
||||
// do the share
|
||||
megolmDecryption.shareKeysWithDevice(keyRequest);
|
||||
|
||||
// it's asynchronous, so we have to wait a bit
|
||||
return Promise.delay(1).then(() => {
|
||||
return awaitEnsureSessions.then(() => {
|
||||
// check that it called encryptMessageForDevice with
|
||||
// appropriate args.
|
||||
expect(mockOlmLib.encryptMessageForDevice.calls.length)
|
||||
|
||||
Reference in New Issue
Block a user