Skip to content

Commit 990ae25

Browse files
committed
test: add tests for status form
1 parent 326d71d commit 990ae25

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

test/screens_test/tabs_test.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@ void main() {
2222
expect(find.text('Home'), findsOneWidget);
2323
expect(find.text('Local'), findsOneWidget);
2424
expect(find.text('Fedi'), findsOneWidget);
25+
26+
// Expect to find the new status button
27+
expect(find.byIcon(Icons.create_rounded), findsOneWidget);
2528
});
2629
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import 'package:flutter_test/flutter_test.dart';
2+
3+
import 'package:flutter/material.dart';
4+
import 'package:feathr/widgets/status_form.dart';
5+
6+
import '../utils.dart';
7+
8+
void main() {
9+
testWidgets(
10+
'Status Form handles invalid data',
11+
(WidgetTester tester) async {
12+
await tester.pumpWidget(
13+
MaterialApp(
14+
home: Scaffold(
15+
body: Column(
16+
children: [
17+
StatusForm(
18+
apiService: getTestApiService(),
19+
onSuccessfulSubmit: (_) => {})
20+
],
21+
),
22+
),
23+
),
24+
);
25+
26+
// Initial render
27+
expect(find.byType(StatusForm), findsOneWidget);
28+
expect(find.text('What\'s on your mind?'), findsOneWidget);
29+
expect(find.text('Post'), findsOneWidget);
30+
expect(find.text('This field should not be empty'), findsNothing);
31+
32+
// Attempting to post without a value
33+
await tester.tap(find.text('Post'));
34+
await tester.pump(const Duration(milliseconds: 100));
35+
expect(find.text('This field should not be empty'), findsOneWidget);
36+
},
37+
);
38+
}

0 commit comments

Comments
 (0)