Skip to content

Commit

Permalink
test(dialog): closeDialog does not close bottom sheets
Browse files Browse the repository at this point in the history
  • Loading branch information
jwelmac committed Oct 8, 2024
1 parent d1a6745 commit ada3d53
Showing 1 changed file with 40 additions and 17 deletions.
57 changes: 40 additions & 17 deletions test/navigation/dialog_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,30 +74,53 @@ void main() {
});
});

testWidgets("Get.dialog close and return value test", (tester) async {
await tester.pumpWidget(
Wrapper(child: Container()),
);
group("Get.closeDialog", () {
testWidgets("Get.closeDialog - closes dialog and returns value",
(tester) async {
await tester.pumpWidget(
Wrapper(child: Container()),
);

await tester.pump();
await tester.pump();

final result = Get.dialog(const YourDialogWidget());
await tester.pumpAndSettle();
final result = Get.dialog(const YourDialogWidget());
await tester.pumpAndSettle();

expect(find.byType(YourDialogWidget), findsOneWidget);
expect(Get.isDialogOpen, true);
expect(find.byType(YourDialogWidget), findsOneWidget);
expect(Get.isDialogOpen, true);

const dialogResult = "My dialog result";
const dialogResult = "My dialog result";

Get.closeDialog(result: dialogResult);
await tester.pumpAndSettle();
Get.closeDialog(result: dialogResult);
await tester.pumpAndSettle();

final returnedResult = await result;
expect(returnedResult, dialogResult);
final returnedResult = await result;
expect(returnedResult, dialogResult);

expect(find.byType(YourDialogWidget), findsNothing);
expect(Get.isDialogOpen, false);
await tester.pumpAndSettle();
expect(find.byType(YourDialogWidget), findsNothing);
expect(Get.isDialogOpen, false);
await tester.pumpAndSettle();
});

testWidgets("Get.closeDialog - does not close bottomsheets",
(tester) async {
await tester.pumpWidget(
Wrapper(child: Container()),
);

await tester.pump();

Get.bottomSheet(const YourDialogWidget());
await tester.pumpAndSettle();

expect(find.byType(YourDialogWidget), findsOneWidget);
expect(Get.isDialogOpen, false);

Get.closeDialog();
await tester.pumpAndSettle();

expect(find.byType(YourDialogWidget), findsOneWidget);
});
});
}

Expand Down

0 comments on commit ada3d53

Please sign in to comment.