Skip to content

Commit

Permalink
test: add tests for status form
Browse files Browse the repository at this point in the history
  • Loading branch information
aitorres committed Jan 19, 2025
1 parent 326d71d commit 990ae25
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/screens_test/tabs_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ void main() {
expect(find.text('Home'), findsOneWidget);
expect(find.text('Local'), findsOneWidget);
expect(find.text('Fedi'), findsOneWidget);

// Expect to find the new status button
expect(find.byIcon(Icons.create_rounded), findsOneWidget);
});
}
38 changes: 38 additions & 0 deletions test/widgets_test/status_form_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'package:flutter_test/flutter_test.dart';

import 'package:flutter/material.dart';
import 'package:feathr/widgets/status_form.dart';

import '../utils.dart';

void main() {
testWidgets(
'Status Form handles invalid data',
(WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Column(
children: [
StatusForm(
apiService: getTestApiService(),
onSuccessfulSubmit: (_) => {})
],
),
),
),
);

// Initial render
expect(find.byType(StatusForm), findsOneWidget);
expect(find.text('What\'s on your mind?'), findsOneWidget);
expect(find.text('Post'), findsOneWidget);
expect(find.text('This field should not be empty'), findsNothing);

// Attempting to post without a value
await tester.tap(find.text('Post'));
await tester.pump(const Duration(milliseconds: 100));
expect(find.text('This field should not be empty'), findsOneWidget);
},
);
}

0 comments on commit 990ae25

Please sign in to comment.