fix failing test now we don't remove invite from collection anymore here

This commit is contained in:
Bruno Windels 2021-05-05 17:47:46 +02:00
parent 45837f7377
commit 15080edfa7

View file

@ -325,28 +325,25 @@ export function tests() {
assert.equal(invite.inviter.displayName, "Alice"); assert.equal(invite.inviter.displayName, "Alice");
assert.equal(invite.inviter.avatarUrl, aliceAvatarUrl); assert.equal(invite.inviter.avatarUrl, aliceAvatarUrl);
}, },
"syncing with membership from invite removes the invite": async assert => { "syncing join sets accepted": async assert => {
let removedEmitted = false; let changeEmitCount = 0;
const invite = new Invite({ const invite = new Invite({
roomId, roomId,
platform: {clock: new MockClock(1003)}, platform: {clock: new MockClock(1003)},
user: {id: "@bob:hs.tld"}, user: {id: "@bob:hs.tld"},
emitCollectionRemove: emittingInvite => {
assert.equal(emittingInvite, invite);
removedEmitted = true;
}
}); });
invite.on("change", () => { changeEmitCount += 1; });
const txn = createStorage(); const txn = createStorage();
const changes = await invite.writeSync("invite", dmInviteFixture, txn, new NullLogItem()); const changes = await invite.writeSync("invite", dmInviteFixture, txn, new NullLogItem());
assert.equal(txn.invitesMap.get(roomId).roomId, roomId); assert.equal(txn.invitesMap.get(roomId).roomId, roomId);
invite.afterSync(changes); invite.afterSync(changes);
const joinChanges = await invite.writeSync("join", null, txn, new NullLogItem()); const joinChanges = await invite.writeSync("join", null, txn, new NullLogItem());
assert(!removedEmitted); assert.strictEqual(changeEmitCount, 0);
invite.afterSync(joinChanges); invite.afterSync(joinChanges);
assert.strictEqual(changeEmitCount, 1);
assert.equal(txn.invitesMap.get(roomId), undefined); assert.equal(txn.invitesMap.get(roomId), undefined);
assert.equal(invite.rejected, false); assert.equal(invite.rejected, false);
assert.equal(invite.accepted, true); assert.equal(invite.accepted, true);
assert(removedEmitted);
} }
} }
} }