File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -57,4 +57,41 @@ void main() {
57
57
await tester.pumpAndSettle ();
58
58
expect (find.text ('entering 123 for cell field' ), findsOneWidget);
59
59
});
60
+
61
+ testWidgets ('URL Field sends request on enter keystroke' , (tester) async {
62
+ bool wasSubmitCalled = false ;
63
+
64
+ void testSubmit (String val) {
65
+ wasSubmitCalled = true ;
66
+ }
67
+
68
+ await tester.pumpWidget (
69
+ MaterialApp (
70
+ title: 'URL Field' ,
71
+ theme: kThemeDataDark,
72
+ home: Scaffold (
73
+ body: Column (children: [
74
+ URLField (
75
+ selectedId: '2' ,
76
+ onFieldSubmitted: testSubmit,
77
+ )
78
+ ]),
79
+ ),
80
+ ),
81
+ );
82
+
83
+ // ensure URLField is blank
84
+ expect (find.byType (TextFormField ), findsOneWidget);
85
+ expect (find.textContaining ('Enter API endpoint ' ), findsOneWidget);
86
+ expect (wasSubmitCalled, false );
87
+
88
+ // modify value and press enter
89
+ var txtForm = find.byKey (const Key ("url-2" ));
90
+ await tester.enterText (txtForm, 'entering 123' );
91
+ await tester.testTextInput.receiveAction (TextInputAction .done);
92
+ await tester.pump ();
93
+
94
+ // check if value was updated
95
+ expect (wasSubmitCalled, true );
96
+ });
60
97
}
You can’t perform that action at this time.
0 commit comments