Skip to content

Commit

Permalink
add exception handler
Browse files Browse the repository at this point in the history
  • Loading branch information
AyushBherwani1998 committed Aug 2, 2023
1 parent 1ef2725 commit 2ccc7b6
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,18 @@ void main() {

expect(unsplashImageModel.images, response);
});

test('should return ServerError upon failure', () async {
when(() => dioMock.get(any())).thenThrow(
DioException(requestOptions: RequestOptions()),
);

final fetchImageFunction = unsplashRemoteDataSourceImpl.fetchImages;

expect(
() => fetchImageFunction.call(1),
throwsA(const TypeMatcher<Exception>()),
);
});
});
}

0 comments on commit 2ccc7b6

Please sign in to comment.