Fix Room Tests

This commit is contained in:
Christian Pauly 2019-06-12 08:40:43 +02:00
parent b7f090e3fa
commit 5343cb8fca

View file

@ -30,7 +30,6 @@ import 'FakeMatrixApi.dart';
void main() { void main() {
/// All Tests related to the Event /// All Tests related to the Event
group("Room", () { group("Room", () {
Client matrix = Client("testclient"); Client matrix = Client("testclient");
matrix.connection.httpClient = FakeMatrixApi(); matrix.connection.httpClient = FakeMatrixApi();
matrix.homeserver = "https://fakeServer.notExisting"; matrix.homeserver = "https://fakeServer.notExisting";
@ -53,6 +52,11 @@ void main() {
final String historyVisibility = "invite"; final String historyVisibility = "invite";
final String joinRules = "invite"; final String joinRules = "invite";
final int now = DateTime.now().millisecondsSinceEpoch; final int now = DateTime.now().millisecondsSinceEpoch;
final String msgtype = "m.text";
final String body = "Hello World";
final String formatted_body = "<b>Hello</b> World";
final String contentJson =
'{"msgtype":"$msgtype","body":"$body","formatted_body":"$formatted_body"}';
final Map<String, dynamic> jsonObj = { final Map<String, dynamic> jsonObj = {
"id": id, "id": id,
@ -83,6 +87,7 @@ void main() {
"power_event_aliases": 0, "power_event_aliases": 0,
"power_event_name": 0, "power_event_name": 0,
"power_event_power_levels": 0, "power_event_power_levels": 0,
"content_json": contentJson,
}; };
room = await Room.getRoomFromTableRow(jsonObj, matrix); room = await Room.getRoomFromTableRow(jsonObj, matrix);
@ -102,13 +107,11 @@ void main() {
expect(room.guestAccess, guestAccess); expect(room.guestAccess, guestAccess);
expect(room.historyVisibility, historyVisibility); expect(room.historyVisibility, historyVisibility);
expect(room.joinRules, joinRules); expect(room.joinRules, joinRules);
expect(room.lastMessage,""); expect(room.lastMessage, "<b>Hello</b> World");
expect(room.timeCreated.toTimeStamp() >= now, true); expect(room.timeCreated.toTimeStamp() >= now, true);
room.powerLevels.forEach((String key, int value) { room.powerLevels.forEach((String key, int value) {
expect(value, 0); expect(value, 0);
}); });
}); });
}); });
} }