mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2025-02-08 18:48:18 +01:00
fix unit tests
This commit is contained in:
parent
45d45cb690
commit
103ae1e789
@ -315,9 +315,10 @@ export class DeviceTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_filterValidMasterKeys(keyQueryResponse, parentLog) {
|
_filterValidMasterKeys(keyQueryResponse, parentLog) {
|
||||||
|
const masterKeys = new Map();
|
||||||
const masterKeysResponse = keyQueryResponse["master_keys"];
|
const masterKeysResponse = keyQueryResponse["master_keys"];
|
||||||
if (!masterKeysResponse) {
|
if (!masterKeysResponse) {
|
||||||
return [];
|
return masterKeys;
|
||||||
}
|
}
|
||||||
const validMasterKeyResponses = Object.entries(masterKeysResponse).filter(([userId, keyInfo]) => {
|
const validMasterKeyResponses = Object.entries(masterKeysResponse).filter(([userId, keyInfo]) => {
|
||||||
if (keyInfo["user_id"] !== userId) {
|
if (keyInfo["user_id"] !== userId) {
|
||||||
@ -328,7 +329,7 @@ export class DeviceTracker {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
const masterKeys = validMasterKeyResponses.reduce((msks, [userId, keyInfo]) => {
|
validMasterKeyResponses.reduce((msks, [userId, keyInfo]) => {
|
||||||
const keyIds = Object.keys(keyInfo.keys);
|
const keyIds = Object.keys(keyInfo.keys);
|
||||||
if (keyIds.length !== 1) {
|
if (keyIds.length !== 1) {
|
||||||
return false;
|
return false;
|
||||||
@ -336,7 +337,7 @@ export class DeviceTracker {
|
|||||||
const masterKey = keyInfo.keys[keyIds[0]];
|
const masterKey = keyInfo.keys[keyIds[0]];
|
||||||
msks.set(userId, masterKey);
|
msks.set(userId, masterKey);
|
||||||
return msks;
|
return msks;
|
||||||
}, new Map());
|
}, masterKeys);
|
||||||
return masterKeys;
|
return masterKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -680,12 +681,14 @@ export function tests() {
|
|||||||
const txn = await storage.readTxn([storage.storeNames.userIdentities]);
|
const txn = await storage.readTxn([storage.storeNames.userIdentities]);
|
||||||
assert.deepEqual(await txn.userIdentities.get("@alice:hs.tld"), {
|
assert.deepEqual(await txn.userIdentities.get("@alice:hs.tld"), {
|
||||||
userId: "@alice:hs.tld",
|
userId: "@alice:hs.tld",
|
||||||
|
masterKey: undefined,
|
||||||
roomIds: [roomId],
|
roomIds: [roomId],
|
||||||
deviceTrackingStatus: TRACKING_STATUS_OUTDATED
|
deviceTrackingStatus: TRACKING_STATUS_OUTDATED
|
||||||
});
|
});
|
||||||
assert.deepEqual(await txn.userIdentities.get("@bob:hs.tld"), {
|
assert.deepEqual(await txn.userIdentities.get("@bob:hs.tld"), {
|
||||||
userId: "@bob:hs.tld",
|
userId: "@bob:hs.tld",
|
||||||
roomIds: [roomId],
|
roomIds: [roomId],
|
||||||
|
masterKey: undefined,
|
||||||
deviceTrackingStatus: TRACKING_STATUS_OUTDATED
|
deviceTrackingStatus: TRACKING_STATUS_OUTDATED
|
||||||
});
|
});
|
||||||
assert.equal(await txn.userIdentities.get("@charly:hs.tld"), undefined);
|
assert.equal(await txn.userIdentities.get("@charly:hs.tld"), undefined);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user