Skip to content

Commit 689e2c4

Browse files
committed
Add a test to verify MatrixClient's room.leave emits on ban.
1 parent 5de1a9b commit 689e2c4

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/MatrixClientTest.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,35 @@ describe('MatrixClient', () => {
14571457
expect(spy.callCount).toBe(1);
14581458
});
14591459

1460+
it('should process bamned rooms as left rooms', async () => {
1461+
const { client: realClient } = createTestClient();
1462+
const client = <ProcessSyncClient>(<any>realClient);
1463+
1464+
const userId = "@syncing:example.org";
1465+
const roomId = "!testing:example.org";
1466+
const events = [
1467+
{
1468+
type: "m.room.member",
1469+
state_key: userId,
1470+
unsigned: { age: 0 },
1471+
content: { membership: "ban" },
1472+
},
1473+
];
1474+
1475+
client.userId = userId;
1476+
1477+
const spy = simple.stub().callFn((rid, ev) => {
1478+
expect(ev).toMatchObject(events[0]);
1479+
expect(rid).toEqual(roomId);
1480+
});
1481+
realClient.on("room.leave", spy);
1482+
1483+
const roomsObj = {};
1484+
roomsObj[roomId] = { timeline: { events: events } };
1485+
await client.processSync({ rooms: { leave: roomsObj } });
1486+
expect(spy.callCount).toBe(1);
1487+
});
1488+
14601489
it('should process left rooms account data', async () => {
14611490
const { client: realClient } = createTestClient();
14621491
const client = <ProcessSyncClient>(<any>realClient);

0 commit comments

Comments
 (0)