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