Skip to content

Commit 794066e

Browse files
authored
Merge pull request #124 from yihong1120/sweep/add-unit-tests-report-service
[Sweep Rules] Add Unit Tests for New Business Logic in Report Service
2 parents ac58742 + 1691a47 commit 794066e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

test/services/report_service_test.dart

+7-7
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ void main() {
3434
license_plate: 'ABC123',
3535
violation: '紅線停車',
3636
status: 'Pending',
37+
address: 'Main St and 1st Ave',
38+
officer: 'Officer123',
39+
mediaFiles: [], // Assuming no media files for simplicity
3740
address: 'Main St and 1st Ave',
3841
officer: 'Officer123',
3942
mediaFiles: [], // Assuming no media files for simplicity
@@ -66,19 +69,16 @@ void main() {
6669
]),
6770
200));
6871

69-
expect(await service.getReports(), isA<List<TrafficViolation>>());
72+
expect(await service.getReports(), equals(<TrafficViolation>[]);
7073
},
7174
);
7275

7376
test(
74-
'getViolation should return a TrafficViolation when the http call completes successfully',
77+
'getViolation should throw an exception when the http call is unsuccessful',
7578
() async {
7679
const int recordId = 1;
77-
when(client.get(isA<Uri>() as Uri))
78-
.thenAnswer((_) async => http.Response(
79-
jsonEncode({
80-
'id': recordId,
81-
'title': 'Parking Violation',
80+
final response404 = http.Response('', 404);
81+
when(client.get(isA<Uri>())).thenAnswer((_) async => response404);
8282
'date': '2024-01-15',
8383
'time': '14:00',
8484
'licensePlate': 'ABC123',

0 commit comments

Comments
 (0)