From dd21721d1182be94560b80ea2b6b4c23bdc4aa6d Mon Sep 17 00:00:00 2001 From: jld3103 Date: Sat, 4 Nov 2023 10:45:34 +0100 Subject: [PATCH] test(neon_dashboard): Use mock cache manager to fix widget tests Signed-off-by: jld3103 --- packages/neon/neon_dashboard/pubspec.yaml | 1 + packages/neon/neon_dashboard/test/widget_test.dart | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/packages/neon/neon_dashboard/pubspec.yaml b/packages/neon/neon_dashboard/pubspec.yaml index 615d025c..6be0c844 100644 --- a/packages/neon/neon_dashboard/pubspec.yaml +++ b/packages/neon/neon_dashboard/pubspec.yaml @@ -26,6 +26,7 @@ dependencies: dev_dependencies: build_runner: ^2.4.6 built_collection: ^5.1.1 + flutter_cache_manager: ^3.3.1 flutter_test: sdk: flutter go_router_builder: ^2.3.4 diff --git a/packages/neon/neon_dashboard/test/widget_test.dart b/packages/neon/neon_dashboard/test/widget_test.dart index c05d5ddb..7a3f7b5a 100644 --- a/packages/neon/neon_dashboard/test/widget_test.dart +++ b/packages/neon/neon_dashboard/test/widget_test.dart @@ -1,5 +1,6 @@ import 'package:built_collection/built_collection.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; import 'package:neon/blocs.dart'; @@ -16,6 +17,8 @@ import 'package:rxdart/rxdart.dart'; class MockAccountsBloc extends Mock implements AccountsBloc {} +class MockCacheManager extends Mock implements DefaultCacheManager {} + Widget wrapWidget(final AccountsBloc accountsBloc, final Widget child) => MaterialApp( localizationsDelegates: DashboardLocalizations.localizationsDelegates, supportedLocales: DashboardLocalizations.supportedLocales, @@ -29,6 +32,8 @@ Widget wrapWidget(final AccountsBloc accountsBloc, final Widget child) => Materi ); void main() { + NeonCachedImage.cacheManager = MockCacheManager(); + final accountsBloc = MockAccountsBloc(); when(() => accountsBloc.activeAccount).thenAnswer( (final invocation) => BehaviorSubject.seeded(