fix desktop dialog close button test

This commit is contained in:
sneurlax 2024-01-26 17:37:55 -06:00
parent 7ea54d9095
commit 6394295167

View file

@ -1,7 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:mockingjay/mockingjay.dart' as mockingjay;
import 'package:stackwallet/models/isar/stack_theme.dart'; import 'package:stackwallet/models/isar/stack_theme.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
@ -11,14 +10,13 @@ import '../../sample_data/theme_json.dart';
void main() { void main() {
testWidgets("test DesktopDialog button pressed", (widgetTester) async { testWidgets("test DesktopDialog button pressed", (widgetTester) async {
final key = UniqueKey(); final navigatorKey = GlobalKey<NavigatorState>();
final navigator = mockingjay.MockNavigator();
await widgetTester.pumpWidget( await widgetTester.pumpWidget(
ProviderScope( ProviderScope(
overrides: [], overrides: [],
child: MaterialApp( child: MaterialApp(
navigatorKey: navigatorKey,
theme: ThemeData( theme: ThemeData(
extensions: [ extensions: [
StackColors.fromStackColorTheme( StackColors.fromStackColorTheme(
@ -28,19 +26,19 @@ void main() {
), ),
], ],
), ),
home: mockingjay.MockNavigatorProvider( home: DesktopDialogCloseButton(
navigator: navigator, key: UniqueKey(),
child: DesktopDialogCloseButton( onPressedOverride: null,
key: key, ),
onPressedOverride: null,
)),
), ),
), ),
); );
await widgetTester.tap(find.byType(AppBarIconButton)); final button = find.byType(AppBarIconButton);
await widgetTester.tap(button);
await widgetTester.pumpAndSettle(); await widgetTester.pumpAndSettle();
mockingjay.verify(() => navigator.pop()).called(1); final navigatorState = navigatorKey.currentState;
expect(navigatorState?.overlay, isNotNull);
}); });
} }