Skip to content

Commit 96869c5

Browse files
authored
Merge pull request #379 from kuhnroyal/chore/type-matchers
Simplify some test type matchers
2 parents ebc9df1 + 4baa62f commit 96869c5

File tree

3 files changed

+57
-57
lines changed

3 files changed

+57
-57
lines changed

test/async_test.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ void main() {
161161
/// We call [signalReady] before the last has completed
162162
expect(
163163
() => getIt.signalReady(null),
164-
throwsA(const TypeMatcher<StateError>()),
164+
throwsStateError,
165165
);
166166
});
167167

@@ -222,7 +222,7 @@ void main() {
222222
/// We call [signalReady] before the last has completed
223223
expect(
224224
() => getIt.signalReady(null),
225-
throwsA(const TypeMatcher<StateError>()),
225+
throwsStateError,
226226
);
227227
});
228228
test('all ready ignoring pending async Singletons', () async {
@@ -396,7 +396,7 @@ void main() {
396396
instanceName: 'Second Instance',
397397
);
398398

399-
expect(getIt.allReady(), throwsA(isA<StateError>()));
399+
expect(getIt.allReady(), throwsStateError);
400400
});
401401
test('ready manual synchronisation of sequence', () async {
402402
final getIt = GetIt.instance;
@@ -639,7 +639,7 @@ void main() {
639639
try {
640640
await getIt.allReady(timeout: const Duration(seconds: 1));
641641
} catch (ex) {
642-
expect(ex, const TypeMatcher<WaitingTimeOutException>());
642+
expect(ex, isA<WaitingTimeOutException>());
643643
final timeOut = ex as WaitingTimeOutException;
644644
expect(timeOut.notReadyYet.contains('null : TestClass'), true);
645645
expect(timeOut.notReadyYet.contains('null : TestClass2'), true);
@@ -666,7 +666,7 @@ void main() {
666666
);
667667

668668
final instance = await getIt.getAsync<TestClass>();
669-
expect(instance, const TypeMatcher<TestClass>());
669+
expect(instance, isA<TestClass>());
670670
});
671671

672672
test('register factory with one Param', () async {
@@ -765,7 +765,7 @@ void main() {
765765

766766
expect(
767767
() => getIt.getAsync<TestClassParam>(param1: 'abc', param2: '3'),
768-
throwsA(const TypeMatcher<TypeError>()),
768+
throwsA(isA<TypeError>()),
769769
);
770770
});
771771

@@ -781,7 +781,7 @@ void main() {
781781

782782
expect(
783783
() => getIt.getAsync<TestClassParam>(),
784-
throwsA(const TypeMatcher<TypeError>()),
784+
throwsA(isA<TypeError>()),
785785
);
786786
});
787787

@@ -795,7 +795,7 @@ void main() {
795795

796796
expect(
797797
() => getIt.get<TestClass>(),
798-
throwsA(const TypeMatcher<AssertionError>()),
798+
throwsA(isA<AssertionError>()),
799799
);
800800
});
801801

@@ -810,7 +810,7 @@ void main() {
810810
await Future.delayed(const Duration(microseconds: 1));
811811
expect(
812812
() => getIt.get<TestClass>(),
813-
throwsA(const TypeMatcher<StateError>()),
813+
throwsStateError,
814814
);
815815
});
816816

@@ -823,7 +823,7 @@ void main() {
823823
);
824824

825825
final instance = await getIt.getAsync<TestClass>();
826-
expect(instance, const TypeMatcher<TestClass>());
826+
expect(instance, isA<TestClass>());
827827
});
828828

829829
test('asyncLazySingleton called with get after wait for ready', () async {
@@ -838,7 +838,7 @@ void main() {
838838
await getIt.isReady<TestClass>(timeout: const Duration(milliseconds: 20));
839839

840840
final instance2 = getIt.get<TestClass>();
841-
expect(instance2, const TypeMatcher<TestClass>());
841+
expect(instance2, isA<TestClass>());
842842
});
843843

844844
test('isReady called on asyncLazySingleton ', () async {
@@ -852,7 +852,7 @@ void main() {
852852
await getIt.isReady<TestClass>(timeout: const Duration(milliseconds: 20));
853853

854854
final instance = getIt.get<TestClass>();
855-
expect(instance, const TypeMatcher<TestClass>());
855+
expect(instance, isA<TestClass>());
856856
});
857857

858858
group("dependency", () {

test/get_it_test.dart

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ void main() {
180180

181181
expect(
182182
() => getIt.get<TestClassParam>(param1: 'abc', param2: '3'),
183-
throwsA(const TypeMatcher<TypeError>()),
183+
throwsA(isA<TypeError>()),
184184
);
185185
});
186186

@@ -195,7 +195,7 @@ void main() {
195195

196196
expect(
197197
() => getIt.get<TestClassParam>(param2: '3'),
198-
throwsA(const TypeMatcher<TypeError>()),
198+
throwsA(isA<TypeError>()),
199199
);
200200
});
201201

@@ -251,7 +251,7 @@ void main() {
251251
await getIt.reset();
252252
expect(
253253
() => getIt.get<TestClass>(),
254-
throwsA(const TypeMatcher<StateError>()),
254+
throwsStateError,
255255
);
256256

257257
expect(destructorCounter, 1);
@@ -266,7 +266,7 @@ void main() {
266266
await getIt.reset();
267267
expect(
268268
() => getIt.get<TestClass>(),
269-
throwsA(const TypeMatcher<StateError>()),
269+
throwsStateError,
270270
);
271271

272272
expect(disposeCounter, 1);
@@ -343,7 +343,7 @@ void main() {
343343

344344
expect(
345345
() => getIt.get<int>(),
346-
throwsA(const TypeMatcher<StateError>()),
346+
throwsStateError,
347347
);
348348

349349
GetIt.I.reset();
@@ -442,7 +442,7 @@ void main() {
442442

443443
expect(
444444
() => getIt(instanceName: 'not there'),
445-
throwsA(const TypeMatcher<AssertionError>()),
445+
throwsA(isA<AssertionError>()),
446446
);
447447
GetIt.I.reset();
448448
});
@@ -702,7 +702,7 @@ void main() {
702702

703703
expect(
704704
() => getIt.get<TestClass>(),
705-
throwsA(const TypeMatcher<StateError>()),
705+
throwsStateError,
706706
);
707707
});
708708

@@ -738,7 +738,7 @@ void main() {
738738

739739
expect(
740740
() => getIt.get<TestClass>(),
741-
throwsA(const TypeMatcher<StateError>()),
741+
throwsStateError,
742742
);
743743
});
744744

@@ -773,7 +773,7 @@ void main() {
773773

774774
expect(
775775
() => getIt.get<TestClass>(),
776-
throwsA(const TypeMatcher<StateError>()),
776+
throwsStateError,
777777
);
778778
});
779779

@@ -808,7 +808,7 @@ void main() {
808808

809809
expect(
810810
() => getIt.get<TestClass>(),
811-
throwsA(const TypeMatcher<StateError>()),
811+
throwsStateError,
812812
);
813813
});
814814

@@ -839,7 +839,7 @@ void main() {
839839

840840
expect(
841841
() => getIt.get<TestClass>(),
842-
throwsA(const TypeMatcher<StateError>()),
842+
throwsStateError,
843843
);
844844
});
845845
test('testing reference counting', () async {
@@ -880,7 +880,7 @@ void main() {
880880

881881
expect(
882882
() => getIt.get<TestClass>(),
883-
throwsA(const TypeMatcher<StateError>()),
883+
throwsStateError,
884884
);
885885
});
886886
test('testing reference counting - unregister', () async {
@@ -921,7 +921,7 @@ void main() {
921921

922922
expect(
923923
() => getIt.get<TestClass>(),
924-
throwsA(const TypeMatcher<StateError>()),
924+
throwsStateError,
925925
);
926926
});
927927

@@ -949,15 +949,15 @@ void main() {
949949

950950
expect(
951951
() => getIt<TestClass>(instanceName: 'instanceName'),
952-
throwsA(const TypeMatcher<StateError>()),
952+
throwsStateError,
953953
);
954954
expect(
955955
getIt<TestClass>(instanceName: 'instanceName2'),
956-
const TypeMatcher<TestClass>(),
956+
isA<TestClass>(),
957957
);
958958
expect(
959959
getIt<TestClass2>(instanceName: 'instanceName'),
960-
const TypeMatcher<TestClass2>(),
960+
isA<TestClass2>(),
961961
);
962962
});
963963

@@ -984,7 +984,7 @@ void main() {
984984

985985
expect(
986986
() => getIt.get<TestClass>(),
987-
throwsA(const TypeMatcher<StateError>()),
987+
throwsStateError,
988988
);
989989
});
990990

@@ -1011,7 +1011,7 @@ void main() {
10111011

10121012
expect(
10131013
() => getIt.get<TestClass>(),
1014-
throwsA(const TypeMatcher<StateError>()),
1014+
throwsStateError,
10151015
);
10161016
});
10171017

@@ -1040,7 +1040,7 @@ void main() {
10401040

10411041
expect(
10421042
() => getIt.get<TestClassDisposable>(),
1043-
throwsA(const TypeMatcher<StateError>()),
1043+
throwsStateError,
10441044
);
10451045
});
10461046

@@ -1061,7 +1061,7 @@ void main() {
10611061

10621062
expect(
10631063
() => getIt<TestClass>(instanceName: 'instanceName'),
1064-
throwsA(const TypeMatcher<StateError>()),
1064+
throwsStateError,
10651065
);
10661066
});
10671067
test('change registration name with type and name', () async {
@@ -1083,11 +1083,11 @@ void main() {
10831083

10841084
expect(
10851085
() => getIt<TestClass>(instanceName: 'instanceName'),
1086-
throwsA(const TypeMatcher<StateError>()),
1086+
throwsStateError,
10871087
);
10881088
expect(
10891089
getIt<TestClass>(instanceName: 'instanceName2'),
1090-
const TypeMatcher<TestClass>(),
1090+
isA<TestClass>(),
10911091
);
10921092
});
10931093

@@ -1108,7 +1108,7 @@ void main() {
11081108
newInstanceName: 'instanceNameExisting',
11091109
);
11101110
},
1111-
throwsA(const TypeMatcher<StateError>()),
1111+
throwsStateError,
11121112
);
11131113
});
11141114

@@ -1131,11 +1131,11 @@ void main() {
11311131

11321132
expect(
11331133
() => getIt<TestClass>(instanceName: 'instanceName'),
1134-
throwsA(const TypeMatcher<StateError>()),
1134+
throwsStateError,
11351135
);
11361136
expect(
11371137
getIt<TestClass>(instanceName: 'instanceName2'),
1138-
const TypeMatcher<TestClass>(),
1138+
isA<TestClass>(),
11391139
);
11401140
});
11411141

@@ -1196,7 +1196,7 @@ void main() {
11961196

11971197
final Injector instance = GetIt.I<Injector>();
11981198

1199-
expect(instance, const TypeMatcher<Injector>());
1199+
expect(instance, isA<Injector>());
12001200
});
12011201

12021202
test('deregister in the same order of registering', () async {
@@ -1257,7 +1257,7 @@ void main() {
12571257

12581258
expect(
12591259
() => getIt<TestClassDisposableWithDependency>(),
1260-
throwsA(const TypeMatcher<StateError>()),
1260+
throwsStateError,
12611261
);
12621262

12631263
await getIt.unregister<TestClassDisposable>();

0 commit comments

Comments
 (0)