diff --git a/test/services/report_service_test.dart b/test/services/report_service_test.dart index 6ec6d49..da631cb 100644 --- a/test/services/report_service_test.dart +++ b/test/services/report_service_test.dart @@ -34,6 +34,9 @@ void main() { license_plate: 'ABC123', violation: '紅線停車', status: 'Pending', + address: 'Main St and 1st Ave', + officer: 'Officer123', + mediaFiles: [], // Assuming no media files for simplicity address: 'Main St and 1st Ave', officer: 'Officer123', mediaFiles: [], // Assuming no media files for simplicity @@ -66,19 +69,16 @@ void main() { ]), 200)); - expect(await service.getReports(), isA>()); + expect(await service.getReports(), equals([]); }, ); test( - 'getViolation should return a TrafficViolation when the http call completes successfully', + 'getViolation should throw an exception when the http call is unsuccessful', () async { const int recordId = 1; - when(client.get(isA() as Uri)) - .thenAnswer((_) async => http.Response( - jsonEncode({ - 'id': recordId, - 'title': 'Parking Violation', + final response404 = http.Response('', 404); + when(client.get(isA())).thenAnswer((_) async => response404); 'date': '2024-01-15', 'time': '14:00', 'licensePlate': 'ABC123',