You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-04 05:02:41 +03:00
test accumulating summary fields
This commit is contained in:
@@ -323,6 +323,60 @@ describe("SyncAccumulator", function() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("summary field", function() {
|
||||||
|
function createSyncResponseWithSummary(summary) {
|
||||||
|
return {
|
||||||
|
next_batch: "abc",
|
||||||
|
rooms: {
|
||||||
|
invite: {},
|
||||||
|
leave: {},
|
||||||
|
join: {
|
||||||
|
"!foo:bar": {
|
||||||
|
account_data: { events: [] },
|
||||||
|
ephemeral: { events: [] },
|
||||||
|
unread_notifications: {},
|
||||||
|
state: {
|
||||||
|
events: [],
|
||||||
|
},
|
||||||
|
summary: summary,
|
||||||
|
timeline: {
|
||||||
|
events: [],
|
||||||
|
prev_batch: "something",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
it("should copy summary properties", function() {
|
||||||
|
sa.accumulate(createSyncResponseWithSummary({
|
||||||
|
"m.heroes": ["@alice:bar"],
|
||||||
|
"m.invited_member_count": 2,
|
||||||
|
}));
|
||||||
|
let summary = sa.getJSON().roomsData.join["!foo:bar"].summary;
|
||||||
|
expect(summary["m.invited_member_count"]).toEqual(2);
|
||||||
|
expect(summary["m.heroes"]).toEqual(["@alice:bar"]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should accumulate summary properties", function() {
|
||||||
|
sa.accumulate(createSyncResponseWithSummary({
|
||||||
|
"m.heroes": ["@alice:bar"],
|
||||||
|
"m.invited_member_count": 2,
|
||||||
|
}));
|
||||||
|
sa.accumulate(createSyncResponseWithSummary({
|
||||||
|
"m.heroes": ["@bob:bar"],
|
||||||
|
"m.joined_member_count": 5,
|
||||||
|
}));
|
||||||
|
|
||||||
|
let summary = sa.getJSON().roomsData.join["!foo:bar"].summary;
|
||||||
|
expect(summary["m.invited_member_count"]).toEqual(2);
|
||||||
|
expect(summary["m.joined_member_count"]).toEqual(5);
|
||||||
|
expect(summary["m.heroes"]).toEqual(["@bob:bar"]);
|
||||||
|
});
|
||||||
|
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
function syncSkeleton(joinObj) {
|
function syncSkeleton(joinObj) {
|
||||||
|
|||||||
Reference in New Issue
Block a user