@@ -1018,13 +1018,15 @@ void main() {
1018
1018
check (store).isLoading.isTrue ();
1019
1019
}
1020
1020
1021
- void checkReloadFailure (FakeAsync async , {
1022
- required FutureOr <void > Function () completeLoading,
1023
- }) async {
1021
+ test ('user logged out before new store is loaded' , () => awaitFakeAsync ((async ) async {
1024
1022
await prepareReload (async );
1025
1023
check (completers ()).single.isCompleted.isFalse ();
1026
1024
1027
- await completeLoading ();
1025
+ // [PerAccountStore.fromInitialSnapshot] requires the account
1026
+ // to be in the global store when called; do so before logging out.
1027
+ final newStore = eg.store (globalStore: globalStore, account: eg.selfAccount);
1028
+ await logOutAccount (globalStore, eg.selfAccount.id);
1029
+ completers ().single.complete (newStore);
1028
1030
check (completers ()).single.isCompleted.isTrue ();
1029
1031
check (globalStore.takeDoRemoveAccountCalls ()).single.equals (eg.selfAccount.id);
1030
1032
@@ -1034,26 +1036,23 @@ void main() {
1034
1036
async .flushTimers ();
1035
1037
// Reload never succeeds and there are no unhandled errors.
1036
1038
check (globalStore.perAccountSync (eg.selfAccount.id)).isNull ();
1037
- }
1038
-
1039
- Future <void > logOutAndCompleteWithNewStore () async {
1040
- // [PerAccountStore.fromInitialSnapshot] requires the account
1041
- // to be in the global store when called; do so before logging out.
1042
- final newStore = eg.store (globalStore: globalStore, account: eg.selfAccount);
1043
- await logOutAccount (globalStore, eg.selfAccount.id);
1044
- completers ().single.complete (newStore);
1045
- }
1046
-
1047
- test ('user logged out before new store is loaded' , () => awaitFakeAsync ((async ) async {
1048
- checkReloadFailure (async , completeLoading: logOutAndCompleteWithNewStore);
1049
1039
}));
1050
1040
1051
- void completeWithApiExceptionUnauthorized () {
1041
+ test ('new store is not loaded, gets HTTP 401 error instead' , () => awaitFakeAsync ((async ) async {
1042
+ await prepareReload (async );
1043
+ check (completers ()).single.isCompleted.isFalse ();
1044
+
1052
1045
completers ().single.completeError (eg.apiExceptionUnauthorized ());
1053
- }
1046
+ async .elapse (Duration .zero);
1047
+ check (completers ()).single.isCompleted.isTrue ();
1048
+ check (globalStore.takeDoRemoveAccountCalls ()).single.equals (eg.selfAccount.id);
1054
1049
1055
- test ('new store is not loaded, gets HTTP 401 error instead' , () => awaitFakeAsync ((async ) async {
1056
- checkReloadFailure (async , completeLoading: completeWithApiExceptionUnauthorized);
1050
+ async .elapse (TestGlobalStore .removeAccountDuration);
1051
+ check (globalStore.perAccountSync (eg.selfAccount.id)).isNull ();
1052
+
1053
+ async .flushTimers ();
1054
+ // Reload never succeeds and there are no unhandled errors.
1055
+ check (globalStore.perAccountSync (eg.selfAccount.id)).isNull ();
1057
1056
}));
1058
1057
});
1059
1058
0 commit comments