[Test] Properly encode fake api responses as utf8. Also remove not needed returns as they do the same as the last return.
Took 15 minutes
This commit is contained in:
parent
bf1a4fe91b
commit
0647df37e3
|
@ -68,30 +68,28 @@ class FakeMatrixApi extends MockClient {
|
||||||
if (api.containsKey(method) && api[method].containsKey(action)) {
|
if (api.containsKey(method) && api[method].containsKey(action)) {
|
||||||
res = api[method][action](data);
|
res = api[method][action](data);
|
||||||
if (res is Map && res.containsKey('errcode')) {
|
if (res is Map && res.containsKey('errcode')) {
|
||||||
return Response(json.encode(res), 405);
|
return Response.bytes(utf8.encode(json.encode(res)), 405);
|
||||||
}
|
}
|
||||||
} else if (method == 'PUT' &&
|
} else if (method == 'PUT' &&
|
||||||
action.contains('/client/r0/sendToDevice/')) {
|
action.contains('/client/r0/sendToDevice/')) {
|
||||||
return Response(json.encode({}), 200);
|
return Response.bytes(utf8.encode(json.encode({})), 200);
|
||||||
} else if (method == 'GET' &&
|
} else if (method == 'GET' &&
|
||||||
action.contains('/client/r0/rooms/') &&
|
action.contains('/client/r0/rooms/') &&
|
||||||
action.contains('/state/m.room.member/')) {
|
action.contains('/state/m.room.member/')) {
|
||||||
res = {'displayname': ''};
|
res = {'displayname': ''};
|
||||||
return Response(json.encode(res), 200);
|
|
||||||
} else if (method == 'PUT' &&
|
} else if (method == 'PUT' &&
|
||||||
action.contains(
|
action.contains(
|
||||||
'/client/r0/rooms/%211234%3AfakeServer.notExisting/send/')) {
|
'/client/r0/rooms/%211234%3AfakeServer.notExisting/send/')) {
|
||||||
res = {'event_id': '\$event${FakeMatrixApi.eventCounter++}'};
|
res = {'event_id': '\$event${FakeMatrixApi.eventCounter++}'};
|
||||||
return Response(json.encode(res), 200);
|
|
||||||
} else {
|
} else {
|
||||||
res = {
|
res = {
|
||||||
'errcode': 'M_UNRECOGNIZED',
|
'errcode': 'M_UNRECOGNIZED',
|
||||||
'error': 'Unrecognized request'
|
'error': 'Unrecognized request'
|
||||||
};
|
};
|
||||||
return Response(json.encode(res), 405);
|
return Response.bytes(utf8.encode(json.encode(res)), 405);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response(json.encode(res), 200);
|
return Response.bytes(utf8.encode(json.encode(res)), 200);
|
||||||
});
|
});
|
||||||
|
|
||||||
static Map<String, dynamic> messagesResponse = {
|
static Map<String, dynamic> messagesResponse = {
|
||||||
|
|
Loading…
Reference in a new issue