Skip to content

Commit fcce4f2

Browse files
committed
store test [nfc]: Remove redundant awaitFakeAsync
1 parent 13aecdd commit fcce4f2

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

test/model/store_test.dart

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -991,24 +991,22 @@ void main() {
991991
check(store).isLoading.isTrue();
992992
}
993993

994-
void checkReloadFailure({
994+
void checkReloadFailure(FakeAsync async, {
995995
required FutureOr<void> Function() completeLoading,
996-
}) {
997-
awaitFakeAsync((async) async {
998-
await prepareReload(async);
999-
check(completers()).single.isCompleted.isFalse();
996+
}) async {
997+
await prepareReload(async);
998+
check(completers()).single.isCompleted.isFalse();
1000999

1001-
await completeLoading();
1002-
check(completers()).single.isCompleted.isTrue();
1003-
check(globalStore.takeDoRemoveAccountCalls()).single.equals(eg.selfAccount.id);
1000+
await completeLoading();
1001+
check(completers()).single.isCompleted.isTrue();
1002+
check(globalStore.takeDoRemoveAccountCalls()).single.equals(eg.selfAccount.id);
10041003

1005-
async.elapse(TestGlobalStore.removeAccountDuration);
1006-
check(globalStore.perAccountSync(eg.selfAccount.id)).isNull();
1004+
async.elapse(TestGlobalStore.removeAccountDuration);
1005+
check(globalStore.perAccountSync(eg.selfAccount.id)).isNull();
10071006

1008-
async.flushTimers();
1009-
// Reload never succeeds and there are no unhandled errors.
1010-
check(globalStore.perAccountSync(eg.selfAccount.id)).isNull();
1011-
});
1007+
async.flushTimers();
1008+
// Reload never succeeds and there are no unhandled errors.
1009+
check(globalStore.perAccountSync(eg.selfAccount.id)).isNull();
10121010
}
10131011

10141012
Future<void> logOutAndCompleteWithNewStore() async {
@@ -1020,15 +1018,15 @@ void main() {
10201018
}
10211019

10221020
test('user logged out before new store is loaded', () => awaitFakeAsync((async) async {
1023-
checkReloadFailure(completeLoading: logOutAndCompleteWithNewStore);
1021+
checkReloadFailure(async, completeLoading: logOutAndCompleteWithNewStore);
10241022
}));
10251023

10261024
void completeWithApiExceptionUnauthorized() {
10271025
completers().single.completeError(eg.apiExceptionUnauthorized());
10281026
}
10291027

10301028
test('new store is not loaded, gets HTTP 401 error instead', () => awaitFakeAsync((async) async {
1031-
checkReloadFailure(completeLoading: completeWithApiExceptionUnauthorized);
1029+
checkReloadFailure(async, completeLoading: completeWithApiExceptionUnauthorized);
10321030
}));
10331031
});
10341032

0 commit comments

Comments
 (0)