1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-06 12:02:40 +03:00

move export test with other Olm tests to have active sessions

This commit is contained in:
Cédric Van Rompay
2020-01-15 17:22:39 +01:00
committed by Cédric Van Rompay
parent 8db38f8e75
commit 3a1cdd37a3

View File

@@ -41,29 +41,7 @@ async function setupSession(initiator, opponent) {
return sid;
}
describe("OlmDevice", () => {
if (!global.Olm) {
logger.warn('Not running megolm unit tests: libolm not present');
return;
}
beforeAll(function() {
return global.Olm.init();
});
let olmDevice;
beforeEach(async function() {
olmDevice = makeOlmDevice();
await olmDevice.init();
});
it('exports picked account and olm sessions', async function() {
console.log('EXPORT RESULT:', await olmDevice.export());
});
});
describe("OlmDecryption", function() {
describe("OlmDevice", function() {
if (!global.Olm) {
logger.warn('Not running megolm unit tests: libolm not present');
return;
@@ -103,6 +81,24 @@ describe("OlmDecryption", function() {
);
});
it('exports picked account and olm sessions', async function() {
await setupSession(aliceOlmDevice, bobOlmDevice);
let exported = await aliceOlmDevice.export();
expect(exported).toHaveProperty('pickleKey');
expect(exported).toHaveProperty('pickledAccount');
expect(exported).toHaveProperty('sessions');
expect(Array.isArray(exported.sessions)).toBe(true);
expect(exported.sessions[0]).toEqual(
expect.objectContaining({
session: expect.any(String),
lastReceivedMessageTs: expect.any(Number),
deviceKey: expect.any(String),
sessionId: expect.any(String),
})
);
});
it("creates only one session at a time", async function() {
// if we call ensureOlmSessionsForDevices multiple times, it should
// only try to create one session at a time, even if the server is