Add API contract Dart models
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:tdc114plus/src/core/network/api_error.dart';
|
||||
|
||||
void main() {
|
||||
test('ApiError parses common error payload', () {
|
||||
final error = ApiError.fromJson({
|
||||
'error': 'Unauthorized',
|
||||
'code': 'unauthorized',
|
||||
'details': {'reason': 'expired'},
|
||||
});
|
||||
|
||||
expect(error.code, 'unauthorized');
|
||||
expect(error.details['reason'], 'expired');
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user