Skip to content

Commit

Permalink
test: Add test case
Browse files Browse the repository at this point in the history
Signed-off-by: CaiJingLong <[email protected]>
  • Loading branch information
CaiJingLong committed Mar 14, 2024
1 parent 8e97597 commit 5b5e5eb
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions dio/test/interceptor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,29 @@ void main() {
expect(response.data['errCode'], 0);
});

test('throw error on request', () async {
final dio = Dio();

const errorMsg = 'interceptor error';

dio.interceptors.add(InterceptorsWrapper(
onResponse: (response, handler) {
throw UnsupportedError('interceptor error');
},
));

expect(
dio.get('https://www.cloudflare.com'),
throwsA(
isA<DioException>().having(
(dioException) => dioException.error,
'Exception',
isA<UnsupportedError>()
.having((p0) => p0.message, 'message', errorMsg)),
),
);
});

group(ImplyContentTypeInterceptor, () {
Dio createDio() {
final dio = Dio();
Expand Down

0 comments on commit 5b5e5eb

Please sign in to comment.