diff --git a/test/src/ui/widgets/charts/retirement_prediction_chart_test.dart b/test/src/ui/widgets/charts/retirement_prediction_chart_test.dart index 58d06d2..08c5a62 100644 --- a/test/src/ui/widgets/charts/retirement_prediction_chart_test.dart +++ b/test/src/ui/widgets/charts/retirement_prediction_chart_test.dart @@ -1,24 +1,44 @@ +import 'package:bloc_test/bloc_test.dart'; +import 'package:financial_dashboard/financial_data/financial_data.dart'; import 'package:financial_dashboard/ui/ui.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:mocktail/mocktail.dart'; import '../../../../helpers/helpers.dart'; +class _MockFinancialDataBloc + extends MockBloc + implements FinancialDataBloc {} + void main() { group('RetirementPredictionChart', () { - Widget buildSubject({ - void Function(String)? onCurrentSavings, - }) => - RetirementPredictionChart(); + late FinancialDataBloc financialDataBloc; + + setUp(() { + financialDataBloc = _MockFinancialDataBloc(); + + when(() => financialDataBloc.state).thenReturn( + FinancialDataState( + savingsDataPoints: createSampleData(), + ), + ); + }); testWidgets('renders LineChartBody', (tester) async { - await tester.pumpExperience(buildSubject()); + await tester.pumpExperience( + RetirementPredictionChart(), + financialDataBloc: financialDataBloc, + ); expect(find.byType(LineChartBody), findsOneWidget); }); testWidgets('shows and hides tooltip on gestures', (tester) async { - await tester.pumpExperience(buildSubject()); + await tester.pumpExperience( + RetirementPredictionChart(), + financialDataBloc: financialDataBloc, + ); final keyFinder = find.byKey(const Key('chart_tooltip')); expect(keyFinder, findsNothing);