From e8d17a5ab3c8d1d0985d820b1922635fcbebb050 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 25 Jun 2015 17:36:21 +0100 Subject: [PATCH] Add missing pagination test --- .../integ/matrix-client-room-timeline.spec.js | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/spec/integ/matrix-client-room-timeline.spec.js b/spec/integ/matrix-client-room-timeline.spec.js index 78325bd84..ef40bb02a 100644 --- a/spec/integ/matrix-client-room-timeline.spec.js +++ b/spec/integ/matrix-client-room-timeline.spec.js @@ -162,6 +162,7 @@ describe("MatrixClient room timelines", function() { describe("paginated events", function() { var sbEvents; + var sbEndTok = "pagin_end"; beforeEach(function() { sbEvents = []; @@ -169,7 +170,7 @@ describe("MatrixClient room timelines", function() { return { chunk: sbEvents, start: "pagin_start", - end: "pagin_end" + end: sbEndTok }; }); }); @@ -264,6 +265,30 @@ describe("MatrixClient room timelines", function() { client.startClient(); httpBackend.flush("/initialSync", 1); }); + + it("should use 'end' as the next pagination token", function(done) { + // set the list of events to return on scrollback + sbEvents = [ + utils.mkMessage({ + user: userId, room: roomId, msg: "I am new" + }) + ]; + + client.on("syncComplete", function() { + var room = client.getRoom(roomId); + expect(room.oldState.paginationToken).toBeDefined(); + + client.scrollback(room, 1).done(function() { + expect(room.oldState.paginationToken).toEqual(sbEndTok); + done(); + }); + + httpBackend.flush("/messages", 1); + httpBackend.flush("/events", 1); + }); + client.startClient(); + httpBackend.flush("/initialSync", 1); + }); }); describe("new events", function() {