From 57ea7d00fb592048ccc08251e75b0c5c8fd80c4a Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Tue, 7 Nov 2023 11:48:05 +0100 Subject: [PATCH] fixed tests --- lib/data/remote_config_service.dart | 6 +++++- lib/providers/remote_config_provider.dart | 3 +-- test/providers/remote_config_provider_test.dart | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/data/remote_config_service.dart b/lib/data/remote_config_service.dart index ae62272..8243dd2 100644 --- a/lib/data/remote_config_service.dart +++ b/lib/data/remote_config_service.dart @@ -33,7 +33,11 @@ class RemoteConfigService { } } - Future fetchConfig() => FirebaseRemoteConfig.instance.fetch(); + Future fetchConfig() async { + // https://github.com/firebase/flutterfire/issues/6196#issuecomment-927751667 + await Future.delayed(const Duration(seconds: 1)); + await FirebaseRemoteConfig.instance.fetch(); + } dynamic getValue(Feature feature) => FirebaseRemoteConfig.instance.getValue(feature.name).toValue(feature); diff --git a/lib/providers/remote_config_provider.dart b/lib/providers/remote_config_provider.dart index 695d3c1..a00b385 100644 --- a/lib/providers/remote_config_provider.dart +++ b/lib/providers/remote_config_provider.dart @@ -26,8 +26,7 @@ class RemoteConfigProviderState extends State { @override void initState() { super.initState(); - // https://github.com/firebase/flutterfire/issues/6196#issuecomment-927751667 - Future.delayed(const Duration(seconds: 1)).then((_) => widget.remoteConfigService.fetchConfig()); + widget.remoteConfigService.fetchConfig(); _updatesSubscription = widget.remoteConfigService.onConfigUpdated().listen( _updateFeatures, onError: (e) => log(e.toString()), diff --git a/test/providers/remote_config_provider_test.dart b/test/providers/remote_config_provider_test.dart index aa6815d..a215cbe 100644 --- a/test/providers/remote_config_provider_test.dart +++ b/test/providers/remote_config_provider_test.dart @@ -18,6 +18,7 @@ void main() { }); setUp(() { + when(() => mockRemoteConfigService.fetchConfig()).thenAnswer((_) async {}); when(() => mockRemoteConfigService.getValue(Feature.unlockProFeaturesText)).thenReturn(false); when(() => mockRemoteConfigService.getAll()).thenReturn({Feature.unlockProFeaturesText: false}); });