Skip to content

Commit a1cce38

Browse files
committed
Adicionando testes do 2-11 ao 2-15
1 parent 2765967 commit a1cce38

File tree

1 file changed

+35
-5
lines changed

1 file changed

+35
-5
lines changed

test/widget_test.dart

+35-5
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,29 @@ void main() {
7878
expect(find.byKey(Key("1-8, 2-7")), hasNoImmediateClip); //1-5, 2-7
7979
expect(find.byType(Tooltip), hasOneLineDescription); //1-5, 2-8
8080
expect(Object(), isNot(hasOneLineDescription)); //2-8
81+
8182
expect(
8283
await tester.runAsync<int>(() async => testForArgumentError()), isNull);
8384
expect(tester.takeException(),
8485
isArgumentError); //2-9 Captura o erro jogado pela função acima
85-
expect(false, isBrowser); //1-5, 2-10
8686

87-
print(Tooltip(message: "q"));
87+
expect(true, isNot(isBrowser)); //2-10
88+
89+
expect(await tester.runAsync<List<String>>(() async => testForCastError()),
90+
isNull);
91+
expect(tester.takeException(), isA<TypeError>()); //2-11
92+
93+
expect(
94+
await tester
95+
.runAsync<int>(() async => testForConcurrentModificationError()),
96+
isNull);
97+
expect(tester.takeException(), isConcurrentModificationError); //2-12
98+
//2-13
99+
expect('', isEmpty); //2-14
100+
expect(<int>[], isEmpty); //2-14
101+
102+
expect(await tester.runAsync<int>(() async => testForException()), isNull);
103+
expect(tester.takeException(), isException); //2-15
88104

89105
// Tap the '+' icon and trigger a frame.
90106
await tester.tap(find.byIcon(Icons.add)); //1-4,
@@ -96,7 +112,18 @@ void main() {
96112
});
97113
}
98114

99-
int testForArgumentError() => throw ArgumentError();
115+
int testForArgumentError() {
116+
final list = <int>[1, 2];
117+
return list[2];
118+
}
119+
120+
List<String> testForCastError() {
121+
final list = <int>[1, 2];
122+
return list.map((e) => e - 1).cast<String>();
123+
}
124+
125+
int testForConcurrentModificationError() => throw ConcurrentModificationError();
126+
int testForException() => (1 ~/ 0);
100127

101128
/*
102129
1 - # Common Finders (ou qualquer parâmetro do tipo Finder usado acima)
@@ -135,9 +162,12 @@ int testForArgumentError() => throw ArgumentError();
135162
Doc aqui: https://api.flutter.dev/flutter/flutter_test/hasOneLineDescription-constant.html
136163
9 isArgumentError
137164
10 isBrowser
138-
11 isCastError
165+
11 isCastError (deprecated) -> isA<TypeError>()
139166
12 isConcurrentModificationError
140-
13 isCyclicInitializationError
167+
Issue relacionada: https://github.com/flutter/flutter/issues/59601
168+
13 isCyclicInitializationError
169+
Doc: https://api.flutter.dev/flutter/dart-core/CyclicInitializationError-class.html
170+
Não achei muito sobre
141171
14 isEmpty
142172
15 isException
143173
16 isFalse

0 commit comments

Comments
 (0)