Skip to content

Commit

Permalink
use inProgressOrSuccess
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasMirbt committed Jul 21, 2024
1 parent 8bbd6c4 commit c311266
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/flutter_login/lib/login/view/login_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class _LoginButton extends StatelessWidget {
Widget build(BuildContext context) {
return BlocBuilder<LoginBloc, LoginState>(
builder: (context, state) {
return state.status.isInProgress
return state.status.isInProgressOrSuccess
? const CircularProgressIndicator()
: ElevatedButton(
key: const Key('loginForm_continue_raisedButton'),
Expand Down
19 changes: 19 additions & 0 deletions examples/flutter_login/test/login/view/login_form_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,25 @@ void main() {
expect(find.byType(CircularProgressIndicator), findsOneWidget);
});

testWidgets('loading indicator is shown when status is submission success',
(tester) async {
when(() => loginBloc.state).thenReturn(
const LoginState(status: FormzSubmissionStatus.success),
);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: BlocProvider.value(
value: loginBloc,
child: LoginForm(),
),
),
),
);
expect(find.byType(ElevatedButton), findsNothing);
expect(find.byType(CircularProgressIndicator), findsOneWidget);
});

testWidgets('continue button is enabled when status is validated',
(tester) async {
when(() => loginBloc.state).thenReturn(const LoginState(isValid: true));
Expand Down

0 comments on commit c311266

Please sign in to comment.