feat(apps): add core API infrastructure
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:social_app/core/api/api_exception.dart';
|
||||
|
||||
void main() {
|
||||
group('ApiException', () {
|
||||
test('creates from DioException with 400 status', () {
|
||||
final dioException = Exception('Bad request');
|
||||
final apiException = ApiException.fromDioError(dioException);
|
||||
|
||||
expect(apiException, isA<ApiException>());
|
||||
expect(apiException.message, contains('Request failed'));
|
||||
});
|
||||
|
||||
test('NetworkException has correct message', () {
|
||||
const exception = NetworkException('No internet');
|
||||
expect(exception.message, 'No internet');
|
||||
});
|
||||
|
||||
test('UnauthorizedException has default message', () {
|
||||
const exception = UnauthorizedException();
|
||||
expect(exception.message, 'Authentication required');
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user