dialog_test.dart
1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'utils/wrapper.dart';
void main() {
  testWidgets("Get.defaultDialog smoke test", (tester) async {
    await tester.pumpWidget(
      Wrapper(child: Container()),
    );
    await tester.pump();
    Get.defaultDialog(
        onConfirm: () {}, middleText: "Dialog made in 3 lines of code");
    await tester.pumpAndSettle();
    expect(find.text("Ok"), findsOneWidget);
  });
  testWidgets("Get.dialog smoke test", (tester) async {
    await tester.pumpWidget(
      Wrapper(child: Container()),
    );
    await tester.pump();
    Get.dialog(const YourDialogWidget());
    await tester.pumpAndSettle();
    expect(find.byType(YourDialogWidget), findsOneWidget);
  });
  testWidgets("Get.dialog close test", (tester) async {
    await tester.pumpWidget(
      Wrapper(child: Container()),
    );
    await tester.pump();
    Get.dialog(const YourDialogWidget());
    await tester.pumpAndSettle();
    expect(find.byType(YourDialogWidget), findsOneWidget);
    // expect(Get.isDialogOpen, true);
    Get.back();
    await tester.pumpAndSettle();
    expect(find.byType(YourDialogWidget), findsNothing);
    // expect(Get.isDialogOpen, false);
    // await tester.pumpAndSettle();
  });
}
class YourDialogWidget extends StatelessWidget {
  const YourDialogWidget({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Container();
  }
}