feat(app): add mockRouter to _AppInternal for improved testing

This commit is contained in:
Artem Luzin m
2025-11-24 16:38:11 +07:00
parent 84e5f5e869
commit c86b4cc0bc

View File

@@ -106,13 +106,19 @@ class _AppState extends State<App> {
/// {@endtemplate} /// {@endtemplate}
class _AppInternal extends StatefulWidget { class _AppInternal extends StatefulWidget {
/// {@macro app_internal} /// {@macro app_internal}
const _AppInternal({required this.diContainer}); const _AppInternal({
required this.diContainer,
@visibleForTesting this.mockRouter,
});
/// Роутер приложения для навигации /// Роутер приложения для навигации
/// Контейнер зависимостей /// Контейнер зависимостей
final DiContainer diContainer; final DiContainer diContainer;
/// Роутер приложения для навигации для тестирования
final GoRouter? mockRouter;
@override @override
State<_AppInternal> createState() => _AppInternalState(); State<_AppInternal> createState() => _AppInternalState();
} }
@@ -124,7 +130,9 @@ class _AppInternalState extends State<_AppInternal> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
router = AppRouter.createRouter(widget.diContainer.debugService); router =
widget.mockRouter ??
AppRouter.createRouter(widget.diContainer.debugService);
} }
@override @override