diff --git a/lib/src/Client.dart b/lib/src/Client.dart index 748d3123..9698c46e 100644 --- a/lib/src/Client.dart +++ b/lib/src/Client.dart @@ -255,7 +255,7 @@ class Client { } /// This endpoint allows the creation, modification and deletion of pushers for this user ID. - Future setPushers(SetPushersRequest data) async { + Future setPushers(SetPushersRequest data) async { final dynamic resp = await connection.jsonRequest( type: HTTPType.POST, action: "/client/r0/pushers/set", @@ -264,9 +264,8 @@ class Client { if (resp is ErrorResponse) { connection.onError.add(resp); - return null; } - return null; + return resp; } } diff --git a/test/Client_test.dart b/test/Client_test.dart index 8a2e9650..a3f1edd0 100644 --- a/test/Client_test.dart +++ b/test/Client_test.dart @@ -26,6 +26,7 @@ import 'dart:async'; import 'package:famedlysdk/src/Client.dart'; import 'package:famedlysdk/src/Connection.dart'; import 'package:famedlysdk/src/User.dart'; +import 'package:famedlysdk/src/requests/SetPushersRequest.dart'; import 'package:famedlysdk/src/responses/ErrorResponse.dart'; import 'package:famedlysdk/src/responses/PushrulesResponse.dart'; import 'package:famedlysdk/src/sync/EventUpdate.dart'; @@ -248,6 +249,25 @@ void main() { expect(pushrules.toJson(), awaited_resp.toJson()); }); + test('setPushers', () async { + final SetPushersRequest data = SetPushersRequest( + app_id: "com.famedly.famedlysdk", + device_display_name: "GitLabCi", + app_display_name: "famedlySDK", + pushkey: "abcdefg", + lang: "en", + data: PusherData( + format: "event_id_only", url: "https://examplepushserver.com")); + final dynamic resp = await matrix.setPushers(data); + expect(resp is ErrorResponse, false); + }); + + test('joinRoomById', () async { + final String roomID = "1234"; + final Map resp = await matrix.joinRoomById(roomID); + expect(resp["room_id"], roomID); + }); + test('Logout when token is unknown', () async { Future loginStateFuture = matrix.connection.onLoginStateChanged.stream.first; diff --git a/test/FakeMatrixApi.dart b/test/FakeMatrixApi.dart index 89a7b51c..41510a7b 100644 --- a/test/FakeMatrixApi.dart +++ b/test/FakeMatrixApi.dart @@ -451,6 +451,8 @@ class FakeMatrixApi extends MockClient { "device_id": "GHTYAJCE" }, "/client/r0/logout": (var reqI) => {}, + "/client/r0/pushers/set": (var reqI) => {}, + "/client/r0/join/1234": (var reqI) => {"room_id": "1234"}, "/client/r0/logout/all": (var reqI) => {}, "/client/r0/createRoom": (var reqI) => { "room_id": "!1234:fakeServer.notExisting",