Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Equartey committed Aug 23, 2024
1 parent 5479bf3 commit 3c3f635
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,34 @@ void main() {
errors,
);

/// GraphQLResponseDecoder should handle a payload with errors.
final response = GraphQLResponseDecoder.instance.decode<String>(
request: GraphQLRequest<String>(
document: '',
),
response: message.payload!.toJson(),
);
expect(
response.errors.first.message,
errorMessage,
);
});
test('WebsocketMessage should decode errors as a Map', () {
const errorMessage = 'Max number of 100 subscriptions reached';
const errorType = 'MaxSubscriptionsReachedError';
const errorMap = {'errorType': errorType, 'message': errorMessage};
final entry = {
'id': 'xyz-456',
'type': 'error',
'payload': {'data': null, 'errors': errorMap},
};
final message = WebSocketMessage.fromJson(entry);
expect(message.messageType, MessageType.error);
expect(
message.payload!.toJson()['errors'],
[errorMap],
);

/// GraphQLResponseDecoder should handle a payload with errors.
final response = GraphQLResponseDecoder.instance.decode<String>(
request: GraphQLRequest<String>(
Expand Down

0 comments on commit 3c3f635

Please sign in to comment.