From 11bd0af90ab49b44fea763e7d400c60a6dbe7e86 Mon Sep 17 00:00:00 2001 From: yihong1120 Date: Mon, 1 Jan 2024 02:53:54 +0800 Subject: [PATCH] remove trst files --- test/report_service_test.dart | 49 ------------------- .../reports/edit_report_screen_test.dart | 25 ---------- .../reports/report_list_screen_test.dart | 17 ------- test/screens/reports/routes_test.dart | 29 ----------- test/social_service_test.dart | 30 ------------ test/widget_test.dart | 30 ------------ 6 files changed, 180 deletions(-) delete mode 100644 test/report_service_test.dart delete mode 100644 test/screens/reports/edit_report_screen_test.dart delete mode 100644 test/screens/reports/report_list_screen_test.dart delete mode 100644 test/screens/reports/routes_test.dart delete mode 100644 test/social_service_test.dart delete mode 100644 test/widget_test.dart diff --git a/test/report_service_test.dart b/test/report_service_test.dart deleted file mode 100644 index e681db9..0000000 --- a/test/report_service_test.dart +++ /dev/null @@ -1,49 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; -import 'package:mockito/mockito.dart'; -import 'package:http/http.dart' as http; -import 'package:traffic_report_front_flutter/services/report_service.dart'; -import 'package:mockito/mockito.dart'; -import 'package:http/http.dart' as http; -import 'package:flutter_test/flutter_test.dart'; - -class MockClient extends Mock implements http.Client {} -class MockReportService extends Mock implements ReportService {} - -void main() { - group('createReport', () { - final client = MockClient(); - final reportService = MockReportService(); - - test('returns true when the http call completes successfully', () async { - when(reportService.createReport(any, any)).thenAnswer((_) async => true); - when(client.post(any, body: anyNamed('body'))).thenAnswer((_) async => http.Response('OK', 200)); - - expect(await reportService.createReport(TrafficViolation(), []), isTrue); - }); - - test('returns false when the http call completes with an error', () async { - when(reportService.createReport(any, any)).thenAnswer((_) async => false); - when(client.post(any, body: anyNamed('body'))).thenAnswer((_) async => http.Response('Not Found', 404)); - - expect(await reportService.createReport(TrafficViolation(), []), isFalse); - }); - - test('returns false when an exception is thrown', () async { - when(reportService.createReport(any, any)).thenThrow(Exception()); - - expect(await reportService.createReport(TrafficViolation(), []), isFalse); - }); - - test('returns false when the media files list is empty', () async { - when(client.send(any)).thenAnswer((_) async => http.Response('OK', 200)); - - expect(await reportService.createReport(TrafficViolation(), []), isFalse); - }); - - test('returns false when the traffic violation object is null', () async { - when(client.send(any)).thenAnswer((_) async => http.Response('OK', 200)); - - expect(await reportService.createReport(null, ['file1', 'file2']), isFalse); - }); - }); -} diff --git a/test/screens/reports/edit_report_screen_test.dart b/test/screens/reports/edit_report_screen_test.dart deleted file mode 100644 index 8d7d54b..0000000 --- a/test/screens/reports/edit_report_screen_test.dart +++ /dev/null @@ -1,25 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; -import 'package:traffic_report_front_flutter/screens/reports/edit_report_screen.dart'; -import 'package:mockito/mockito.dart'; - -class MockReportService extends Mock implements ReportService {} - -void main() { - group('EditReportScreen', () { - test('_loadViolation function should fetch violation data and update state', () { - // TODO: Implement test - }); - - test('_pickMedia function should open media picker and add selected files to list', () { - // TODO: Implement test - }); - - test('_removeMedia function should remove specified file from list', () { - // TODO: Implement test - }); - - test('_submitReport function should submit report and handle errors', () { - // TODO: Implement test - }); - }); -} diff --git a/test/screens/reports/report_list_screen_test.dart b/test/screens/reports/report_list_screen_test.dart deleted file mode 100644 index 2308b8c..0000000 --- a/test/screens/reports/report_list_screen_test.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; -import 'package:traffic_report_front_flutter/screens/reports/report_list_screen.dart'; -import 'package:mockito/mockito.dart'; - -class MockReportService extends Mock implements ReportService {} - -void main() { - group('ReportListScreen', () { - test('_fetchReports function should fetch reports and update state', () { - // TODO: Implement test - }); - - test('List display logic should correctly display reports and fetch more when necessary', () { - // TODO: Implement test - }); - }); -} diff --git a/test/screens/reports/routes_test.dart b/test/screens/reports/routes_test.dart deleted file mode 100644 index 0fd0426..0000000 --- a/test/screens/reports/routes_test.dart +++ /dev/null @@ -1,29 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; -import 'package:traffic_report_front_flutter/screens/reports/routes.dart'; - -void main() { - testWidgets('"/reports" should return ReportListPage', (WidgetTester tester) async { - final widget = reportsRoutes['/reports']!(tester); - expect(widget, isInstanceOf()); - }); - - testWidgets('"/reports/create" should return CreateReportPage', (WidgetTester tester) async { - final widget = reportsRoutes['/reports/create']!(tester); - expect(widget, isInstanceOf()); - }); - - testWidgets('"/reports/details" should return ReportDetailsPage', (WidgetTester tester) async { - final widget = reportsRoutes['/reports/details']!(tester); - expect(widget, isInstanceOf()); - }); - - testWidgets('"/reports/edit" should return ReportEditPage', (WidgetTester tester) async { - final widget = reportsRoutes['/reports/edit']!(tester); - expect(widget, isInstanceOf()); - }); - - testWidgets('"/reports/paged" should return ReportPagedListPage', (WidgetTester tester) async { - final widget = reportsRoutes['/reports/paged']!(tester); - expect(widget, isInstanceOf()); - }); -} diff --git a/test/social_service_test.dart b/test/social_service_test.dart deleted file mode 100644 index 6e87a2f..0000000 --- a/test/social_service_test.dart +++ /dev/null @@ -1,30 +0,0 @@ -/// Tests for the 'launchUrl' function in the 'SocialService' class. -import 'package:flutter_test/flutter_test.dart'; -import 'package:mockito/mockito.dart'; -import 'package:traffic_report_front_flutter/services/social_service.dart'; -import 'package:url_launcher/url_launcher.dart'; - -class MockUrlLauncher extends Mock implements UrlLauncher {} - -/// The 'main' function is the entry point for the tests and contains a group of tests for the 'launchUrl' function. -void main() { - group('launchUrl', () { - final mockUrlLauncher = MockUrlLauncher(); - final socialService = SocialService(); - - /// Tests if the 'launchUrl' function can successfully launch a URL. - test('launches URL successfully', () async { - when(mockUrlLauncher.canLaunch(any)).thenAnswer((_) async => true); - when(mockUrlLauncher.launch(any)).thenAnswer((_) async => true); - - expect(await socialService.launchUrl('http://valid.url'), completes); - }); - - /// Tests if the 'launchUrl' function throws an exception when the URL cannot be launched. - test('throws an exception when URL cannot be launched', () async { - when(mockUrlLauncher.canLaunch(any)).thenAnswer((_) async => false); - - expect(() async => await socialService.launchUrl('http://invalid.url'), throwsA(isA())); - }); - }); -} diff --git a/test/widget_test.dart b/test/widget_test.dart deleted file mode 100644 index fdbd587..0000000 --- a/test/widget_test.dart +++ /dev/null @@ -1,30 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility in the flutter_test package. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - -import 'package:traffic_report_front_flutter/main.dart'; - -void main() { - testWidgets('Counter increments smoke test', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(const TrafficReportApp()); - - // Verify that our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); - - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); - await tester.pump(); - - // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); - }); -}