From de125441d151d45f83c81a65c39ffa2a3791f24d Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 20 Apr 2021 17:34:45 +0200 Subject: [PATCH] add write/load test for Invite --- src/matrix/room/Invite.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/matrix/room/Invite.js b/src/matrix/room/Invite.js index 6215498a..967241d2 100644 --- a/src/matrix/room/Invite.js +++ b/src/matrix/room/Invite.js @@ -248,5 +248,25 @@ export function tests() { assert.equal(invite.inviter.displayName, "Alice"); assert.equal(invite.inviter.avatarUrl, aliceAvatarUrl); }, + "load persisted invite has correct fields": async assert => { + const writeInvite = new Invite({ + roomId, + clock: new MockClock(1003), + user: {id: "@bob:hs.tld"} + }); + const txn = createStorage(); + await writeInvite.writeSync("invite", dmInviteFixture, txn, new NullLogItem()); + const invite = new Invite({roomId}); + invite.load(txn.invitesMap.get(roomId)); + assert.equal(invite.name, "Alice"); + assert.equal(invite.avatarUrl, aliceAvatarUrl); + assert.equal(invite.timestamp, 1003); + assert.equal(invite.isEncrypted, true); + assert.equal(invite.isDirectMessage, true); + assert(invite.inviter); + assert.equal(invite.inviter.userId, "@alice:hs.tld"); + assert.equal(invite.inviter.displayName, "Alice"); + assert.equal(invite.inviter.avatarUrl, aliceAvatarUrl); + }, } }