Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
feat: pulse on thinking and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RuiMiguel committed Dec 5, 2023
1 parent b9d1704 commit 34cc3da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class QuestionsResource {
}
body = response.body;
} else {
await Future<void>.delayed(const Duration(seconds: 8));
await Future<void>.delayed(const Duration(seconds: 4));

body = switch (query) {
'What is flutter?' => FakeResponses.whatIsFlutterResponse,
Expand Down
31 changes: 6 additions & 25 deletions test/home/widgets/thinking_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';
import 'package:phased/phased.dart';

import '../../helpers/helpers.dart';

Expand All @@ -30,15 +29,15 @@ void main() {
testWidgets('renders correctly', (tester) async {
await tester.pumpApp(bootstrap());

expect(find.byType(CirclesAnimation), findsOneWidget);
expect(find.byType(PulseAnimationView), findsOneWidget);
expect(find.byType(TextArea), findsOneWidget);
});

testWidgets('renders correctly when in portrait mode', (tester) async {
tester.setViewSize(size: Size(600, 800));
await tester.pumpApp(bootstrap());

expect(find.byType(CirclesAnimation), findsOneWidget);
expect(find.byType(PulseAnimationView), findsOneWidget);
expect(find.byType(TextArea), findsOneWidget);
});

Expand Down Expand Up @@ -68,48 +67,30 @@ void main() {
expect(forwardExitStatuses, equals([Status.thinkingToResults]));
});

group('ThinkingAnimationView', () {
Widget bootstrap(PhasedState<ThinkingAnimationPhase> state) =>
BlocProvider.value(
group('PulseAnimationView', () {
Widget bootstrap() => BlocProvider.value(
value: homeBloc,
child: Material(
child: ThinkingAnimationView(
animationState: state,
),
child: PulseAnimationView(),
),
);

testWidgets(
'animation changes correctly',
(tester) async {
final animationState = PhasedState<ThinkingAnimationPhase>(
values: ThinkingAnimationPhase.values,
initialValue: ThinkingAnimationPhase.initial,
);
final streamController = StreamController<HomeState>();
whenListen(
homeBloc,
streamController.stream,
initialState: const HomeState(),
);

expect(animationState.value, equals(ThinkingAnimationPhase.initial));
await tester.pumpApp(bootstrap(animationState));

expect(
animationState.value,
equals(ThinkingAnimationPhase.thinkingIn),
);
await tester.pumpApp(bootstrap());

streamController.add(
const HomeState(status: Status.thinkingToResults),
);
await tester.pump();

expect(
animationState.value,
equals(ThinkingAnimationPhase.thinkingOut),
);
},
);
});
Expand Down

0 comments on commit 34cc3da

Please sign in to comment.