Skip to content

Commit

Permalink
[Tests] Test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Nov 6, 2022
1 parent ed4f985 commit b6a712f
Showing 1 changed file with 174 additions and 2 deletions.
176 changes: 174 additions & 2 deletions test/application/splash/splash_bloc_test.dart
Expand Up @@ -67,6 +67,12 @@ void main() {
language: _language,
result: _getUpdateResult(AppResourceUpdateResultType.unknownError),
noResourcesHasBeenDownloaded: false,
isLoading: false,
isUpdating: false,
updateFailed: true,
canSkipUpdate: true,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
)
],
);
Expand All @@ -89,6 +95,12 @@ void main() {
language: _language,
result: _getUpdateResult(AppResourceUpdateResultType.unknownError),
noResourcesHasBeenDownloaded: true,
isLoading: false,
isUpdating: false,
updateFailed: true,
canSkipUpdate: false,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
)
],
);
Expand All @@ -111,6 +123,12 @@ void main() {
language: _language,
result: _getUpdateResult(AppResourceUpdateResultType.noUpdatesAvailable),
noResourcesHasBeenDownloaded: false,
isLoading: true,
isUpdating: false,
updateFailed: false,
canSkipUpdate: true,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
)
],
);
Expand All @@ -133,6 +151,40 @@ void main() {
language: _language,
result: _getUpdateResult(AppResourceUpdateResultType.needsLatestAppVersion),
noResourcesHasBeenDownloaded: false,
isLoading: false,
isUpdating: false,
updateFailed: false,
canSkipUpdate: true,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
)
],
);

blocTest<SplashBloc, SplashState>(
'needs latest app version on first install',
build: () {
final result = _getUpdateResult(AppResourceUpdateResultType.needsLatestAppVersion);
final resourceService = MockResourceService();
when(resourceService.checkForUpdates(_defaultAppVersion, _defaultResourcesVersion)).thenAnswer((_) => Future.value(result));
final settingsService = MockSettingsService();
when(settingsService.noResourcesHasBeenDownloaded).thenReturn(true);
when(settingsService.resourceVersion).thenReturn(_defaultResourcesVersion);
return _getBloc(resourceService, settingsService: settingsService);
},
act: (bloc) => bloc.add(const SplashEvent.init()),
expect: () => [
SplashState.loaded(
updateResultType: AppResourceUpdateResultType.needsLatestAppVersion,
language: _language,
result: _getUpdateResult(AppResourceUpdateResultType.needsLatestAppVersion),
noResourcesHasBeenDownloaded: true,
isLoading: false,
isUpdating: false,
updateFailed: true,
canSkipUpdate: false,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: true,
)
],
);
Expand All @@ -144,7 +196,7 @@ void main() {
final resourceService = MockResourceService();
when(resourceService.checkForUpdates(_defaultAppVersion, _defaultResourcesVersion)).thenAnswer((_) => Future.value(result));
final settingsService = MockSettingsService();
when(settingsService.noResourcesHasBeenDownloaded).thenReturn(false);
when(settingsService.noResourcesHasBeenDownloaded).thenReturn(true);
when(settingsService.resourceVersion).thenReturn(_defaultResourcesVersion);
return _getBloc(resourceService, settingsService: settingsService);
},
Expand All @@ -154,7 +206,13 @@ void main() {
updateResultType: AppResourceUpdateResultType.noInternetConnectionForFirstInstall,
language: _language,
result: _getUpdateResult(AppResourceUpdateResultType.noInternetConnectionForFirstInstall),
noResourcesHasBeenDownloaded: false,
noResourcesHasBeenDownloaded: true,
isLoading: false,
isUpdating: false,
updateFailed: true,
canSkipUpdate: false,
noInternetConnectionOnFirstInstall: true,
needsLatestAppVersionOnFirstInstall: false,
)
],
);
Expand Down Expand Up @@ -189,6 +247,12 @@ void main() {
keyNames: _keyNames,
),
noResourcesHasBeenDownloaded: false,
isLoading: false,
isUpdating: false,
updateFailed: false,
canSkipUpdate: true,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
)
],
);
Expand Down Expand Up @@ -221,13 +285,25 @@ void main() {
keyNames: _keyNames,
),
noResourcesHasBeenDownloaded: false,
isLoading: false,
isUpdating: false,
updateFailed: false,
canSkipUpdate: true,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
),
act: (bloc) => bloc.add(const SplashEvent.init(retry: true)),
expect: () => [
SplashState.loaded(
updateResultType: AppResourceUpdateResultType.retrying,
language: _language,
noResourcesHasBeenDownloaded: false,
isLoading: true,
isUpdating: false,
updateFailed: false,
canSkipUpdate: true,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
),
SplashState.loaded(
updateResultType: AppResourceUpdateResultType.updatesAvailable,
Expand All @@ -239,6 +315,12 @@ void main() {
keyNames: _keyNames,
),
noResourcesHasBeenDownloaded: false,
isLoading: false,
isUpdating: false,
updateFailed: false,
canSkipUpdate: true,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
),
],
);
Expand All @@ -252,6 +334,12 @@ void main() {
language: _language,
result: _getUpdateResult(AppResourceUpdateResultType.updatesAvailable),
noResourcesHasBeenDownloaded: false,
isLoading: false,
isUpdating: false,
updateFailed: false,
canSkipUpdate: false,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
),
build: () => _getBloc(MockResourceService()),
act: (bloc) => bloc
Expand All @@ -265,20 +353,38 @@ void main() {
progress: 10,
result: _getUpdateResult(AppResourceUpdateResultType.updatesAvailable),
noResourcesHasBeenDownloaded: false,
isLoading: false,
isUpdating: false,
updateFailed: false,
canSkipUpdate: false,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
),
SplashState.loaded(
updateResultType: AppResourceUpdateResultType.updatesAvailable,
language: _language,
progress: 50,
result: _getUpdateResult(AppResourceUpdateResultType.updatesAvailable),
noResourcesHasBeenDownloaded: false,
isLoading: false,
isUpdating: false,
updateFailed: false,
canSkipUpdate: false,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
),
SplashState.loaded(
updateResultType: AppResourceUpdateResultType.updatesAvailable,
language: _language,
progress: 100,
result: _getUpdateResult(AppResourceUpdateResultType.updatesAvailable),
noResourcesHasBeenDownloaded: false,
isLoading: false,
isUpdating: false,
updateFailed: false,
canSkipUpdate: false,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
),
],
);
Expand All @@ -290,6 +396,12 @@ void main() {
language: _language,
result: _getUpdateResult(AppResourceUpdateResultType.updatesAvailable),
noResourcesHasBeenDownloaded: false,
isLoading: false,
isUpdating: false,
updateFailed: false,
canSkipUpdate: false,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
),
build: () => _getBloc(MockResourceService()),
act: (bloc) => bloc
Expand All @@ -302,6 +414,12 @@ void main() {
progress: 100,
result: _getUpdateResult(AppResourceUpdateResultType.updatesAvailable),
noResourcesHasBeenDownloaded: false,
isLoading: false,
isUpdating: false,
updateFailed: false,
canSkipUpdate: false,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
)
],
);
Expand All @@ -313,6 +431,12 @@ void main() {
language: _language,
result: _getUpdateResult(AppResourceUpdateResultType.updatesAvailable),
noResourcesHasBeenDownloaded: false,
isLoading: false,
isUpdating: false,
updateFailed: false,
canSkipUpdate: false,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
),
build: () => _getBloc(MockResourceService()),
act: (bloc) => bloc
Expand All @@ -325,6 +449,12 @@ void main() {
progress: 10,
result: _getUpdateResult(AppResourceUpdateResultType.updatesAvailable),
noResourcesHasBeenDownloaded: false,
isLoading: false,
isUpdating: false,
updateFailed: false,
canSkipUpdate: false,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
)
],
);
Expand All @@ -336,6 +466,12 @@ void main() {
language: _language,
result: _getUpdateResult(AppResourceUpdateResultType.updatesAvailable),
noResourcesHasBeenDownloaded: false,
isLoading: false,
isUpdating: false,
updateFailed: false,
canSkipUpdate: false,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
),
build: () => _getBloc(MockResourceService()),
act: (bloc) => bloc.add(const SplashEvent.progressChanged(progress: -1)),
Expand All @@ -351,6 +487,12 @@ void main() {
language: _language,
result: _getUpdateResult(AppResourceUpdateResultType.updatesAvailable, resourceVersion: 2),
noResourcesHasBeenDownloaded: false,
isLoading: false,
isUpdating: false,
updateFailed: false,
canSkipUpdate: false,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
),
build: () => _getBloc(MockResourceService()),
act: (bloc) => bloc.add(const SplashEvent.updateCompleted(applied: true, resourceVersion: 2)),
Expand All @@ -360,6 +502,12 @@ void main() {
language: _language,
progress: 100,
noResourcesHasBeenDownloaded: false,
isLoading: true,
isUpdating: false,
updateFailed: false,
canSkipUpdate: true,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
)
],
);
Expand All @@ -371,6 +519,12 @@ void main() {
language: _language,
result: _getUpdateResult(AppResourceUpdateResultType.updatesAvailable, resourceVersion: 2),
noResourcesHasBeenDownloaded: false,
isLoading: false,
isUpdating: false,
updateFailed: false,
canSkipUpdate: false,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
),
build: () {
final settingsService = MockSettingsService();
Expand All @@ -385,6 +539,12 @@ void main() {
language: _language,
progress: 100,
noResourcesHasBeenDownloaded: false,
isLoading: false,
isUpdating: false,
updateFailed: true,
canSkipUpdate: true,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
)
],
);
Expand All @@ -396,6 +556,12 @@ void main() {
language: _language,
result: _getUpdateResult(AppResourceUpdateResultType.updatesAvailable, resourceVersion: 2),
noResourcesHasBeenDownloaded: true,
isLoading: false,
isUpdating: false,
updateFailed: false,
canSkipUpdate: false,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
),
build: () {
final settingsService = MockSettingsService();
Expand All @@ -410,6 +576,12 @@ void main() {
language: _language,
progress: 100,
noResourcesHasBeenDownloaded: true,
isLoading: false,
isUpdating: false,
updateFailed: true,
canSkipUpdate: false,
noInternetConnectionOnFirstInstall: false,
needsLatestAppVersionOnFirstInstall: false,
),
],
);
Expand Down

0 comments on commit b6a712f

Please sign in to comment.