Merge branch 'MTRNord/utf8-encode-fake-api-responses' into 'master'
[Tests] Properly encode fake api responses as utf8. Also remove not needed returns as they do the same as the last return. Closes #84 See merge request famedly/famedlysdk!392
This commit is contained in:
commit
845d0cf791
|
@ -47,6 +47,7 @@ class FakeMatrixApi extends MockClient {
|
|||
final dynamic data =
|
||||
method == 'GET' ? request.url.queryParameters : request.body;
|
||||
dynamic res = {};
|
||||
var statusCode = 200;
|
||||
|
||||
//print('\$method request to $action with Data: $data');
|
||||
|
||||
|
@ -68,30 +69,28 @@ class FakeMatrixApi extends MockClient {
|
|||
if (api.containsKey(method) && api[method].containsKey(action)) {
|
||||
res = api[method][action](data);
|
||||
if (res is Map && res.containsKey('errcode')) {
|
||||
return Response(json.encode(res), 405);
|
||||
statusCode = 405;
|
||||
}
|
||||
} else if (method == 'PUT' &&
|
||||
action.contains('/client/r0/sendToDevice/')) {
|
||||
return Response(json.encode({}), 200);
|
||||
res = {};
|
||||
} else if (method == 'GET' &&
|
||||
action.contains('/client/r0/rooms/') &&
|
||||
action.contains('/state/m.room.member/')) {
|
||||
res = {'displayname': ''};
|
||||
return Response(json.encode(res), 200);
|
||||
} else if (method == 'PUT' &&
|
||||
action.contains(
|
||||
'/client/r0/rooms/%211234%3AfakeServer.notExisting/send/')) {
|
||||
res = {'event_id': '\$event${FakeMatrixApi.eventCounter++}'};
|
||||
return Response(json.encode(res), 200);
|
||||
} else {
|
||||
res = {
|
||||
'errcode': 'M_UNRECOGNIZED',
|
||||
'error': 'Unrecognized request'
|
||||
};
|
||||
return Response(json.encode(res), 405);
|
||||
statusCode = 405;
|
||||
}
|
||||
|
||||
return Response(json.encode(res), 200);
|
||||
return Response.bytes(utf8.encode(json.encode(res)), statusCode);
|
||||
});
|
||||
|
||||
static Map<String, dynamic> messagesResponse = {
|
||||
|
|
Loading…
Reference in a new issue