Skip to content

Commit

Permalink
Add a test to verify MatrixClient's room.leave emits on ban.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gnuxie committed Feb 2, 2025
1 parent 5de1a9b commit 689e2c4
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/MatrixClientTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1457,6 +1457,35 @@ describe('MatrixClient', () => {
expect(spy.callCount).toBe(1);
});

it('should process bamned rooms as left rooms', async () => {
const { client: realClient } = createTestClient();
const client = <ProcessSyncClient>(<any>realClient);

const userId = "@syncing:example.org";
const roomId = "!testing:example.org";
const events = [
{
type: "m.room.member",
state_key: userId,
unsigned: { age: 0 },
content: { membership: "ban" },
},
];

client.userId = userId;

const spy = simple.stub().callFn((rid, ev) => {
expect(ev).toMatchObject(events[0]);
expect(rid).toEqual(roomId);
});
realClient.on("room.leave", spy);

const roomsObj = {};
roomsObj[roomId] = { timeline: { events: events } };
await client.processSync({ rooms: { leave: roomsObj } });
expect(spy.callCount).toBe(1);
});

it('should process left rooms account data', async () => {
const { client: realClient } = createTestClient();
const client = <ProcessSyncClient>(<any>realClient);
Expand Down

0 comments on commit 689e2c4

Please sign in to comment.