Skip to content

Commit

Permalink
removed print
Browse files Browse the repository at this point in the history
  • Loading branch information
escamoteur committed Nov 5, 2024
1 parent 00579d9 commit 589f27a
Showing 1 changed file with 24 additions and 30 deletions.
54 changes: 24 additions & 30 deletions test/async_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -349,40 +349,34 @@ void main() {
});

test('ready automatic signalling for async Singletons', () async {
try {
final getIt = GetIt.instance;
await getIt.reset();
final getIt = GetIt.instance;
await getIt.reset();

getIt.registerSingletonAsync<TestClass>(
() async => TestClass(internalCompletion: false).init(),
);
getIt.registerSingletonAsync<TestClass2>(
() async {
final instance =
TestClass2(internalCompletion: false, initMsDelay: 50);
await instance.init();
return instance;
},
);
getIt.registerSingletonAsync<TestClass>(
() async => TestClass2(internalCompletion: false).init(),
instanceName: 'Second Instance',
);
getIt.registerSingletonAsync<TestClass>(
() async => TestClass(internalCompletion: false).init(),
);
getIt.registerSingletonAsync<TestClass2>(
() async {
final instance = TestClass2(internalCompletion: false, initMsDelay: 50);
await instance.init();
return instance;
},
);
getIt.registerSingletonAsync<TestClass>(
() async => TestClass2(internalCompletion: false).init(),
instanceName: 'Second Instance',
);

expect(getIt.isReadySync<TestClass>(), false);
expect(getIt.isReadySync<TestClass2>(), false);
expect(
getIt.isReadySync<TestClass>(instanceName: 'Second Instance'), false);
expect(getIt.isReadySync<TestClass>(), false);
expect(getIt.isReadySync<TestClass2>(), false);
expect(
getIt.isReadySync<TestClass>(instanceName: 'Second Instance'), false);

await getIt.allReady();
await getIt.allReady();

expect(getIt.isReadySync<TestClass>(), true);
expect(getIt.isReadySync<TestClass2>(), true);
expect(
getIt.isReadySync<TestClass>(instanceName: 'Second Instance'), true);
} on Exception catch (e) {
print(e);
}
expect(getIt.isReadySync<TestClass>(), true);
expect(getIt.isReadySync<TestClass2>(), true);
expect(getIt.isReadySync<TestClass>(instanceName: 'Second Instance'), true);
});

test('isReady propagates Error', () async {
Expand Down

0 comments on commit 589f27a

Please sign in to comment.