chore: Add markasdm/group tests
This commit is contained in:
parent
694187d5f1
commit
064b84305d
|
|
@ -1233,17 +1233,21 @@ class Room {
|
||||||
|
|
||||||
/// Removes this room from all direct chat tags.
|
/// Removes this room from all direct chat tags.
|
||||||
Future<void> removeFromDirectChat() async {
|
Future<void> removeFromDirectChat() async {
|
||||||
final directChats = client.directChats;
|
final directChats = client.directChats.copy();
|
||||||
if (directChats[directChatMatrixID] is List &&
|
for (final k in directChats.keys) {
|
||||||
directChats[directChatMatrixID].contains(id)) {
|
if (directChats[k] is List && directChats[k].contains(id)) {
|
||||||
directChats[directChatMatrixID].remove(id);
|
directChats[k].remove(id);
|
||||||
} else {
|
}
|
||||||
return;
|
}
|
||||||
} // Nothing to do here
|
|
||||||
|
|
||||||
await client.setAccountDataPerRoom(
|
directChats.removeWhere((_, v) => v is List && v.isEmpty);
|
||||||
|
|
||||||
|
if (directChats == client.directChats) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await client.setAccountData(
|
||||||
client.userID!,
|
client.userID!,
|
||||||
id,
|
|
||||||
'm.direct',
|
'm.direct',
|
||||||
directChats,
|
directChats,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -312,7 +312,68 @@ void main() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('create', () async {
|
test('markasdm', () async {
|
||||||
|
FakeMatrixApi.calledEndpoints.clear();
|
||||||
|
await room.sendTextEvent('/markasdm @fakealice:example.com');
|
||||||
|
expect(
|
||||||
|
json.decode(FakeMatrixApi
|
||||||
|
.calledEndpoints[
|
||||||
|
'/client/v3/user/%40test%3AfakeServer.notExisting/account_data/m.direct']
|
||||||
|
?.first)?['@alice:example.com'],
|
||||||
|
['!1234:fakeServer.notExisting']);
|
||||||
|
expect(
|
||||||
|
json.decode(FakeMatrixApi
|
||||||
|
.calledEndpoints[
|
||||||
|
'/client/v3/user/%40test%3AfakeServer.notExisting/account_data/m.direct']
|
||||||
|
?.first)?['@fakealice:example.com'],
|
||||||
|
['!1234:fakeServer.notExisting']);
|
||||||
|
expect(
|
||||||
|
json
|
||||||
|
.decode(FakeMatrixApi
|
||||||
|
.calledEndpoints[
|
||||||
|
'/client/v3/user/%40test%3AfakeServer.notExisting/account_data/m.direct']
|
||||||
|
?.first)
|
||||||
|
.entries
|
||||||
|
.any((e) =>
|
||||||
|
e.key != '@fakealice:example.com' &&
|
||||||
|
e.key != '@alice:example.com' &&
|
||||||
|
e.value.contains('!1234:fakeServer.notExisting')),
|
||||||
|
false);
|
||||||
|
|
||||||
|
FakeMatrixApi.calledEndpoints.clear();
|
||||||
|
await room.sendTextEvent('/markasdm');
|
||||||
|
expect(
|
||||||
|
json.decode(FakeMatrixApi
|
||||||
|
.calledEndpoints[
|
||||||
|
'/client/v3/user/%40test%3AfakeServer.notExisting/account_data/m.direct']
|
||||||
|
?.first)?[''],
|
||||||
|
['!1234:fakeServer.notExisting']);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('markasgroup', () async {
|
||||||
|
FakeMatrixApi.calledEndpoints.clear();
|
||||||
|
await room.sendTextEvent('/markasgroup');
|
||||||
|
expect(
|
||||||
|
json
|
||||||
|
.decode(FakeMatrixApi
|
||||||
|
.calledEndpoints[
|
||||||
|
'/client/v3/user/%40test%3AfakeServer.notExisting/account_data/m.direct']
|
||||||
|
?.first)
|
||||||
|
?.containsKey('@alice:example.com'),
|
||||||
|
false);
|
||||||
|
expect(
|
||||||
|
json
|
||||||
|
.decode(FakeMatrixApi
|
||||||
|
.calledEndpoints[
|
||||||
|
'/client/v3/user/%40test%3AfakeServer.notExisting/account_data/m.direct']
|
||||||
|
?.first)
|
||||||
|
.entries
|
||||||
|
.any((e) => (e.value as List<dynamic>)
|
||||||
|
.contains('!1234:fakeServer.notExisting')),
|
||||||
|
false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('clearcache', () async {
|
||||||
await room.sendTextEvent('/clearcache');
|
await room.sendTextEvent('/clearcache');
|
||||||
expect(room.client.prevBatch, null);
|
expect(room.client.prevBatch, null);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue