From d0fbe455987b05e4786db8b8ffc11ad5338aae72 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Sat, 4 Jan 2020 15:43:53 +0100 Subject: [PATCH] =?UTF-8?q?[Room]=C2=A0Enhance=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/Room_test.dart | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/test/Room_test.dart b/test/Room_test.dart index e96feda..719108f 100644 --- a/test/Room_test.dart +++ b/test/Room_test.dart @@ -73,7 +73,33 @@ void main() { "heroes": heroes.join(","), }; - room = await Room.getRoomFromTableRow(jsonObj, matrix); + Function states = () async => [ + { + "content": {"join_rule": "public"}, + "event_id": "143273582443PhrSn:example.org", + "origin_server_ts": 1432735824653, + "room_id": id, + "sender": "@example:example.org", + "state_key": "", + "type": "m.room.join_rules", + "unsigned": {"age": 1234} + } + ]; + + Function roomAccountData = () async => [ + { + "content": {"foo": "bar"}, + "room_id": id, + "type": "com.test.foo" + } + ]; + + room = await Room.getRoomFromTableRow( + jsonObj, + matrix, + states: states(), + roomAccountData: roomAccountData(), + ); expect(room.id, id); expect(room.membership, membership); @@ -83,6 +109,8 @@ void main() { expect(room.mInvitedMemberCount, notificationCount); expect(room.mHeroes, heroes); expect(room.displayname, "alice, bob, charley"); + expect(room.getState("m.room.join_rules").content["join_rule"], "public"); + expect(room.roomAccountData["com.test.foo"].content["foo"], "bar"); room.states["m.room.canonical_alias"] = Event( senderId: "@test:example.com", @@ -126,8 +154,6 @@ void main() { content: {"url": "mxc://testurl"}, stateKey: ""); expect(room.avatar.mxc, "mxc://testurl"); - - expect(room.lastEvent, null); room.states["m.room.message"] = Event( senderId: "@test:example.com", typeKey: "m.room.message",