Skip to content
Snippets Groups Projects
Commit e6e2f0b3 authored by Luke Barnard's avatar Luke Barnard
Browse files

Fix the tests such that they mock EventTimelineSet.prototype.getTimelineForEvent

parent 1a0e480b
Branches 246-creating-room-state
Tags
No related merge requests found
...@@ -12,6 +12,22 @@ import expect from 'expect'; ...@@ -12,6 +12,22 @@ import expect from 'expect';
const ROOM_ID = "roomId"; const ROOM_ID = "roomId";
const USER_ID = "userId"; const USER_ID = "userId";
function createTimelineSet() {
// XXX: this is a horrid hack
return {
room: {
roomId: ROOM_ID,
getUnfilteredTimelineSet: function() {
return this;
},
},
getTimelineForEvent: function() {
return this.timeline;
},
timeline: null, // Must be set after creation
};
}
/* /*
* create a timeline with a bunch (default 3) events. * create a timeline with a bunch (default 3) events.
* baseIndex is 1 by default. * baseIndex is 1 by default.
...@@ -24,13 +40,9 @@ function createTimeline(numEvents, baseIndex) { ...@@ -24,13 +40,9 @@ function createTimeline(numEvents, baseIndex) {
baseIndex = 1; baseIndex = 1;
} }
// XXX: this is a horrid hack const timelineSet = createTimelineSet();
const timelineSet = { room: { roomId: ROOM_ID }};
timelineSet.room.getUnfilteredTimelineSet = function() {
return timelineSet;
};
const timeline = new EventTimeline(timelineSet); const timeline = new EventTimeline(timelineSet);
timelineSet.timeline = timeline;
// add the events after the baseIndex first // add the events after the baseIndex first
addEventsToTimeline(timeline, numEvents - baseIndex, false); addEventsToTimeline(timeline, numEvents - baseIndex, false);
...@@ -153,7 +165,8 @@ describe("TimelineWindow", function() { ...@@ -153,7 +165,8 @@ describe("TimelineWindow", function() {
let timelineSet; let timelineSet;
let client; let client;
function createWindow(timeline, opts) { function createWindow(timeline, opts) {
timelineSet = {}; timelineSet = createTimelineSet();
timelineSet.timeline = timeline;
client = {}; client = {};
client.getEventTimeline = function(timelineSet0, eventId0) { client.getEventTimeline = function(timelineSet0, eventId0) {
expect(timelineSet0).toBe(timelineSet); expect(timelineSet0).toBe(timelineSet);
...@@ -186,7 +199,7 @@ describe("TimelineWindow", function() { ...@@ -186,7 +199,7 @@ describe("TimelineWindow", function() {
const timeline = createTimeline(); const timeline = createTimeline();
const eventId = timeline.getEvents()[1].getId(); const eventId = timeline.getEvents()[1].getId();
const timelineSet = {}; const timelineSet = createTimelineSet();
const client = {}; const client = {};
client.getEventTimeline = function(timelineSet0, eventId0) { client.getEventTimeline = function(timelineSet0, eventId0) {
expect(timelineSet0).toBe(timelineSet); expect(timelineSet0).toBe(timelineSet);
...@@ -209,7 +222,7 @@ describe("TimelineWindow", function() { ...@@ -209,7 +222,7 @@ describe("TimelineWindow", function() {
const eventId = timeline.getEvents()[1].getId(); const eventId = timeline.getEvents()[1].getId();
const timelineSet = {}; const timelineSet = createTimelineSet();
const client = {}; const client = {};
const timelineWindow = new TimelineWindow(client, timelineSet); const timelineWindow = new TimelineWindow(client, timelineSet);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment