Browse Source

test(neon_dashboard): Use mock cache manager to fix widget tests

Signed-off-by: jld3103 <jld3103yt@gmail.com>
pull/1106/head
jld3103 1 year ago
parent
commit
dd21721d11
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 1
      packages/neon/neon_dashboard/pubspec.yaml
  2. 5
      packages/neon/neon_dashboard/test/widget_test.dart

1
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

5
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(

Loading…
Cancel
Save