Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: added tests for files under lib/routes folder #394

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions test/routes/app_pages_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:taskwarrior/app/modules/about/bindings/about_binding.dart';
import 'package:taskwarrior/app/modules/about/views/about_view.dart';
import 'package:taskwarrior/app/modules/home/bindings/home_binding.dart';
import 'package:taskwarrior/app/modules/splash/bindings/splash_binding.dart';

import 'package:taskwarrior/app/routes/app_pages.dart';
import 'package:taskwarrior/app/modules/home/views/home_view.dart';
import 'package:taskwarrior/app/modules/splash/views/splash_view.dart';

import 'package:taskwarrior/app/modules/detailRoute/views/detail_route_view.dart';
import 'package:taskwarrior/app/modules/detailRoute/bindings/detail_route_binding.dart';
import 'package:taskwarrior/app/modules/manageTaskServer/views/manage_task_server_view.dart';
import 'package:taskwarrior/app/modules/manageTaskServer/bindings/manage_task_server_binding.dart';
import 'package:taskwarrior/app/modules/onboarding/views/onboarding_view.dart';
import 'package:taskwarrior/app/modules/onboarding/bindings/onboarding_binding.dart';
import 'package:taskwarrior/app/modules/profile/views/profile_view.dart';
import 'package:taskwarrior/app/modules/profile/bindings/profile_binding.dart';
import 'package:taskwarrior/app/modules/reports/views/reports_view.dart';
import 'package:taskwarrior/app/modules/reports/bindings/reports_binding.dart';
import 'package:taskwarrior/app/modules/settings/views/settings_view.dart';
import 'package:taskwarrior/app/modules/settings/bindings/settings_binding.dart';

void main() {
group('AppPages Test', () {
test('Initial route is correct', () {
expect(AppPages.INITIAL, Routes.SPLASH);
});

test('All routes should be defined correctly', () {
final routes = AppPages.routes;

expect(routes.length, 9);

expect(
routes.any((route) =>
route.name == Routes.HOME &&
route.page() is HomeView &&
route.binding is HomeBinding),
true,
);
expect(
routes.any((route) =>
route.name == Routes.SPLASH &&
route.page() is SplashView &&
route.binding is SplashBinding),
true,
);
expect(
routes.any((route) =>
route.name == Routes.ABOUT &&
route.page() is AboutView &&
route.binding is AboutBinding),
true,
);
expect(
routes.any((route) =>
route.name == Routes.DETAIL_ROUTE &&
route.page() is DetailRouteView &&
route.binding is DetailRouteBinding),
true,
);
expect(
routes.any((route) =>
route.name == Routes.MANAGE_TASK_SERVER &&
route.page() is ManageTaskServerView &&
route.binding is ManageTaskServerBinding),
true,
);
expect(
routes.any((route) =>
route.name == Routes.ONBOARDING &&
route.page() is OnboardingView &&
route.binding is OnboardingBinding),
true,
);
expect(
routes.any((route) =>
route.name == Routes.PROFILE &&
route.page() is ProfileView &&
route.binding is ProfileBinding),
true,
);
expect(
routes.any((route) =>
route.name == Routes.REPORTS &&
route.page() is ReportsView &&
route.binding is ReportsBinding),
true,
);
expect(
routes.any((route) =>
route.name == Routes.SETTINGS &&
route.page() is SettingsView &&
route.binding is SettingsBinding),
true,
);
});

test('All routes are accessible without crashing', () {
final routes = AppPages.routes;

for (var route in routes) {
expect(() => route.page(), returnsNormally,
reason: 'Route ${route.name} should not throw errors');
}
});
});
}
16 changes: 16 additions & 0 deletions test/routes/app_routes_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:taskwarrior/app/routes/app_pages.dart';

void main() {
test('Routes should be defined correctly', () {
expect(Routes.HOME, '/home');
expect(Routes.ONBOARDING, '/onboarding');
expect(Routes.SPLASH, '/splash');
expect(Routes.MANAGE_TASK_SERVER, '/manage-task-server');
expect(Routes.DETAIL_ROUTE, '/detail-route');
expect(Routes.PROFILE, '/profile');
expect(Routes.ABOUT, '/about');
expect(Routes.REPORTS, '/reports');
expect(Routes.SETTINGS, '/settings');
});
}
Loading