Skip to content

Commit

Permalink
test: savings prediction chart
Browse files Browse the repository at this point in the history
  • Loading branch information
jsgalarraga committed Aug 5, 2024
1 parent a5e2e9a commit 34f0f06
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions test/src/ui/widgets/charts/retirement_prediction_chart_test.dart
Original file line number Diff line number Diff line change
@@ -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<FinancialDataEvent, FinancialDataState>
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);
Expand Down

0 comments on commit 34f0f06

Please sign in to comment.