|
1 | 1 | import { MatrixEvent } from "../../src/models/event"; |
| 2 | +import { RoomEvent } from "../../src/models/room"; |
2 | 3 | import { EventTimeline } from "../../src/models/event-timeline"; |
3 | 4 | import { EventType } from "../../src/@types/event"; |
4 | 5 | import * as utils from "../test-utils/test-utils"; |
@@ -696,25 +697,33 @@ describe("MatrixClient syncing", function() { |
696 | 697 |
|
697 | 698 | const markerEventId = nextSyncData.rooms.join[roomOne].timeline.events[0].event_id; |
698 | 699 |
|
| 700 | + // Only do the first sync |
| 701 | + httpBackend.when("GET", "/sync").respond(200, normalFirstSync); |
| 702 | + client.startClient(); |
| 703 | + await Promise.all([ |
| 704 | + httpBackend.flushAllExpected(), |
| 705 | + awaitSyncEvent(), |
| 706 | + ]); |
| 707 | + |
| 708 | + // Get the room after the first sync so the room is created |
| 709 | + const room = client.getRoom(roomOne); |
| 710 | + |
699 | 711 | let emitCount = 0; |
700 | | - client.on("Room.historyImportedWithinTimeline", function(markerEvent, room) { |
| 712 | + room.on(RoomEvent.historyImportedWithinTimeline, function(markerEvent, room) { |
701 | 713 | expect(markerEvent.getId()).toEqual(markerEventId); |
702 | 714 | expect(room.roomId).toEqual(roomOne); |
703 | 715 | emitCount += 1; |
704 | 716 | }); |
705 | 717 |
|
706 | | - httpBackend.when("GET", "/sync").respond(200, normalFirstSync); |
| 718 | + // Now do a subsequent sync with the marker event |
707 | 719 | httpBackend.when("GET", "/sync").respond(200, nextSyncData); |
708 | | - |
709 | | - client.startClient(); |
710 | 720 | await Promise.all([ |
711 | 721 | httpBackend.flushAllExpected(), |
712 | | - awaitSyncEvent(2), |
| 722 | + awaitSyncEvent(), |
713 | 723 | ]); |
714 | 724 |
|
715 | | - const room = client.getRoom(roomOne); |
716 | 725 | expect(room.getTimelineNeedsRefresh()).toEqual(true); |
717 | | - // Make sure "Room.historyImportedWithinTimeline" was emitted |
| 726 | + // Make sure `RoomEvent.historyImportedWithinTimeline` was emitted |
718 | 727 | expect(emitCount).toEqual(1); |
719 | 728 | expect(room.getLastMarkerEventIdProcessed()).toEqual(markerEventId); |
720 | 729 | }); |
|
0 commit comments