|
1 | | -import 'package:flutter/material.dart'; |
2 | | -import 'package:flutter/services.dart'; |
3 | 1 | import 'package:flutter_test/flutter_test.dart'; |
4 | | -import 'package:get/get_navigation/src/root/get_material_app.dart'; |
5 | | -import 'package:mockito/annotations.dart'; |
6 | | -import 'package:mockito/mockito.dart'; |
7 | | -import 'package:taskwarrior/app/utils/app_settings/app_settings.dart'; |
8 | | -import 'package:taskwarrior/main.dart' as app; |
| 2 | +import 'package:get/get.dart'; |
| 3 | +import 'package:taskwarrior/app/routes/app_pages.dart'; |
9 | 4 |
|
10 | | -class MockMethodChannel extends Mock implements MethodChannel {} |
11 | | - |
12 | | -class AppSettingsService { |
13 | | - Future<void> init() => AppSettings.init(); |
14 | | -} |
15 | | - |
16 | | -class MockAppSettingsService extends Mock implements AppSettingsService {} |
17 | | - |
18 | | -@GenerateMocks([MockMethodChannel]) |
19 | 5 | void main() { |
20 | | - late MockAppSettingsService mockAppSettingsService; |
21 | | - |
22 | | - setUp(() { |
23 | | - mockAppSettingsService = MockAppSettingsService(); |
24 | | - }); |
25 | | - |
26 | | - testWidgets('App initializes and renders correctly', |
27 | | - (WidgetTester tester) async { |
28 | | - when(mockAppSettingsService.init()).thenAnswer((_) async {}); |
29 | | - |
30 | | - await tester.pumpWidget( |
31 | | - MaterialApp( |
32 | | - home: Builder( |
33 | | - builder: (context) { |
34 | | - app.main(); |
35 | | - return Container(); |
36 | | - }, |
37 | | - ), |
38 | | - ), |
39 | | - ); |
40 | | - |
41 | | - await tester.pumpAndSettle(); |
42 | | - |
43 | | - verify(mockAppSettingsService.init()).called(1); |
44 | | - |
45 | | - expect(find.byType(GetMaterialApp), findsOneWidget); |
| 6 | + group('Main App Initialization', () { |
| 7 | + testWidgets('App initializes with the correct route', |
| 8 | + (WidgetTester tester) async { |
| 9 | + await tester.pumpWidget(GetMaterialApp( |
| 10 | + title: "Application", |
| 11 | + initialRoute: AppPages.INITIAL, |
| 12 | + getPages: AppPages.routes, |
| 13 | + )); |
| 14 | + |
| 15 | + // Check if the app starts at the correct initial route |
| 16 | + expect(Get.currentRoute, equals(AppPages.INITIAL)); |
| 17 | + }); |
| 18 | + |
| 19 | + testWidgets('Splash screen displays the correct content', |
| 20 | + (WidgetTester tester) async { |
| 21 | + await tester.pumpWidget(GetMaterialApp( |
| 22 | + title: "Application", |
| 23 | + initialRoute: AppPages.INITIAL, |
| 24 | + getPages: AppPages.routes, |
| 25 | + )); |
| 26 | + |
| 27 | + // Check if the splash screen contains the expected text |
| 28 | + expect(find.text("Setting up the app..."), findsOneWidget); |
| 29 | + }); |
46 | 30 | }); |
47 | 31 | } |
0 commit comments