Skip to content

Commit d4edb6f

Browse files
committed
Tests
1 parent 8ba0c98 commit d4edb6f

14 files changed

+790
-83
lines changed

lib/src/collection/max_length_validator.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class MaxLengthValidator<T> extends BaseValidator<T> {
1515

1616
@override
1717
String get translatedErrorText =>
18-
FormBuilderLocalizations.current.equalLengthErrorText(maxLength);
18+
FormBuilderLocalizations.current.maxLengthErrorText(maxLength);
1919

2020
@override
2121
String? validateValue(T valueCandidate) {

test/src/bool/has_numeric_chars_validator_test.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ void main() {
122122
() {
123123
// Arrange
124124
final HasNumericCharsValidator validator = HasNumericCharsValidator(
125-
regex: RegExp('[0-9]'), errorText: customErrorMessage);
125+
regex: RegExp('[0-9]'),
126+
errorText: customErrorMessage,
127+
);
126128
const String value = 'abc';
127129

128130
// Act

test/src/bool/has_special_chars_validator_test.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ void main() {
102102
final String? result = validator.validate(value);
103103

104104
// Assert
105-
expect(result,
106-
FormBuilderLocalizations.current.containsSpecialCharErrorText(1));
105+
expect(
106+
result,
107+
FormBuilderLocalizations.current.containsSpecialCharErrorText(1),
108+
);
107109
});
108110

109111
test('should return null when the value is an empty string', () {
@@ -150,7 +152,9 @@ void main() {
150152
() {
151153
// Arrange
152154
final HasSpecialCharsValidator validator = HasSpecialCharsValidator(
153-
regex: RegExp('[^A-Za-z0-9]'), errorText: customErrorMessage);
155+
regex: RegExp('[^A-Za-z0-9]'),
156+
errorText: customErrorMessage,
157+
);
154158
const String value = 'abc123';
155159

156160
// Act

test/src/collection/equal_length_validator_test.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ void main() {
161161
const int length = 3;
162162
const EqualLengthValidator<List<String>> validator =
163163
EqualLengthValidator<List<String>>(length);
164-
const List<String> value = ['a', 'b', 'c'];
164+
const List<String> value = <String>['a', 'b', 'c'];
165165

166166
// Act
167167
final String? result = validator.validate(value);
@@ -177,7 +177,7 @@ void main() {
177177
const int length = 3;
178178
const EqualLengthValidator<List<String>> validator =
179179
EqualLengthValidator<List<String>>(length);
180-
const List<String> value = ['a', 'b'];
180+
const List<String> value = <String>['a', 'b'];
181181

182182
// Act
183183
final String? result = validator.validate(value);
@@ -199,7 +199,7 @@ void main() {
199199
const int length = 3;
200200
const EqualLengthValidator<List<String>> validator =
201201
EqualLengthValidator<List<String>>(length);
202-
const List<String> value = ['a', 'b', 'c', 'd'];
202+
const List<String> value = <String>['a', 'b', 'c', 'd'];
203203

204204
// Act
205205
final String? result = validator.validate(value);
@@ -224,7 +224,7 @@ void main() {
224224
length,
225225
errorText: customErrorMessage,
226226
);
227-
const List<String> value = ['a', 'b'];
227+
const List<String> value = <String>['a', 'b'];
228228

229229
// Act
230230
final String? result = validator.validate(value);
@@ -274,7 +274,7 @@ void main() {
274274
const int length = 3;
275275
const EqualLengthValidator<List<String>> validator =
276276
EqualLengthValidator<List<String>>(length, checkNullOrEmpty: false);
277-
const List<String> value = [];
277+
const List<String> value = <String>[];
278278

279279
// Act
280280
final String? result = validator.validate(value);
@@ -288,7 +288,7 @@ void main() {
288288
const int length = 3;
289289
const EqualLengthValidator<List<String>> validator =
290290
EqualLengthValidator<List<String>>(length);
291-
const List<String> value = [];
291+
const List<String> value = <String>[];
292292

293293
// Act
294294
final String? result = validator.validate(value);

test/src/collection/max_length_validator_test.dart

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ void main() {
66
final Faker faker = Faker.instance;
77
final String customErrorMessage = faker.lorem.sentence();
88

9-
group('Max length - String', () {
9+
group('MaxLengthValidator - String', () {
1010
test('should return null when the value has the exact maximum length', () {
1111
// Arrange
1212
const int maxLength = 5;
@@ -51,9 +51,11 @@ void main() {
5151
// Assert
5252
expect(result, isNotNull);
5353
expect(
54-
result,
55-
equals(
56-
FormBuilderLocalizations.current.maxLengthErrorText(maxLength)));
54+
result,
55+
equals(
56+
FormBuilderLocalizations.current.maxLengthErrorText(maxLength),
57+
),
58+
);
5759
});
5860

5961
test(
@@ -100,9 +102,11 @@ void main() {
100102
// Assert
101103
expect(result, isNotNull);
102104
expect(
103-
result,
104-
equals(
105-
FormBuilderLocalizations.current.maxLengthErrorText(maxLength)));
105+
result,
106+
equals(
107+
FormBuilderLocalizations.current.maxLengthErrorText(maxLength),
108+
),
109+
);
106110
});
107111

108112
test(
@@ -136,19 +140,21 @@ void main() {
136140
// Assert
137141
expect(result, isNotNull);
138142
expect(
139-
result,
140-
equals(
141-
FormBuilderLocalizations.current.maxLengthErrorText(maxLength)));
143+
result,
144+
equals(
145+
FormBuilderLocalizations.current.maxLengthErrorText(maxLength),
146+
),
147+
);
142148
});
143149
});
144150

145-
group('Max length - List', () {
151+
group('MaxLengthValidator - List', () {
146152
test('should return null when the list has the exact maximum length', () {
147153
// Arrange
148154
const int maxLength = 3;
149155
const MaxLengthValidator<List<String>> validator =
150156
MaxLengthValidator<List<String>>(maxLength);
151-
const List<String> value = ['a', 'b', 'c'];
157+
const List<String> value = <String>['a', 'b', 'c'];
152158

153159
// Act
154160
final String? result = validator.validate(value);
@@ -163,7 +169,7 @@ void main() {
163169
const int maxLength = 3;
164170
const MaxLengthValidator<List<String>> validator =
165171
MaxLengthValidator<List<String>>(maxLength);
166-
const List<String> value = ['a', 'b'];
172+
const List<String> value = <String>['a', 'b'];
167173

168174
// Act
169175
final String? result = validator.validate(value);
@@ -179,17 +185,19 @@ void main() {
179185
const int maxLength = 3;
180186
const MaxLengthValidator<List<String>> validator =
181187
MaxLengthValidator<List<String>>(maxLength);
182-
const List<String> value = ['a', 'b', 'c', 'd'];
188+
const List<String> value = <String>['a', 'b', 'c', 'd'];
183189

184190
// Act
185191
final String? result = validator.validate(value);
186192

187193
// Assert
188194
expect(result, isNotNull);
189195
expect(
190-
result,
191-
equals(
192-
FormBuilderLocalizations.current.maxLengthErrorText(maxLength)));
196+
result,
197+
equals(
198+
FormBuilderLocalizations.current.maxLengthErrorText(maxLength),
199+
),
200+
);
193201
});
194202

195203
test(
@@ -198,9 +206,11 @@ void main() {
198206
// Arrange
199207
const int maxLength = 3;
200208
final MaxLengthValidator<List<String>> validator =
201-
MaxLengthValidator<List<String>>(maxLength,
202-
errorText: customErrorMessage);
203-
const List<String> value = ['a', 'b', 'c', 'd'];
209+
MaxLengthValidator<List<String>>(
210+
maxLength,
211+
errorText: customErrorMessage,
212+
);
213+
const List<String> value = <String>['a', 'b', 'c', 'd'];
204214

205215
// Act
206216
final String? result = validator.validate(value);
@@ -237,9 +247,11 @@ void main() {
237247
// Assert
238248
expect(result, isNotNull);
239249
expect(
240-
result,
241-
equals(
242-
FormBuilderLocalizations.current.maxLengthErrorText(maxLength)));
250+
result,
251+
equals(
252+
FormBuilderLocalizations.current.maxLengthErrorText(maxLength),
253+
),
254+
);
243255
});
244256

245257
test('should return null when the list is empty and null check is disabled',
@@ -248,7 +260,7 @@ void main() {
248260
const int maxLength = 3;
249261
const MaxLengthValidator<List<String>> validator =
250262
MaxLengthValidator<List<String>>(maxLength, checkNullOrEmpty: false);
251-
const List<String> value = [];
263+
const List<String> value = <String>[];
252264

253265
// Act
254266
final String? result = validator.validate(value);
@@ -262,17 +274,19 @@ void main() {
262274
const int maxLength = 3;
263275
const MaxLengthValidator<List<String>> validator =
264276
MaxLengthValidator<List<String>>(maxLength);
265-
const List<String> value = [];
277+
const List<String> value = <String>[];
266278

267279
// Act
268280
final String? result = validator.validate(value);
269281

270282
// Assert
271283
expect(result, isNotNull);
272284
expect(
273-
result,
274-
equals(
275-
FormBuilderLocalizations.current.maxLengthErrorText(maxLength)));
285+
result,
286+
equals(
287+
FormBuilderLocalizations.current.maxLengthErrorText(maxLength),
288+
),
289+
);
276290
});
277291
});
278292
}

test/src/core/aggregate_validator_test.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ void main() {
99
group('Aggregate -', () {
1010
test('should return null when all validators return null', () {
1111
// Arrange
12-
const AggregateValidator validator = AggregateValidator(validators: <IsTrueValidator>[
13-
IsTrueValidator(),
14-
IsTrueValidator(),
15-
],);
12+
const AggregateValidator validator = AggregateValidator(
13+
validators: <IsTrueValidator>[
14+
IsTrueValidator(),
15+
IsTrueValidator(),
16+
],
17+
);
1618
const bool value = true;
1719

1820
// Act

test/src/core/or_validator_test.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,13 @@ void main() {
6060
'should return the custom error message when the value is not valid for any validator',
6161
() {
6262
// Arrange
63-
final OrValidator validator = OrValidator(<FormFieldValidator>[
64-
const EqualValidator('a'),
65-
const EqualValidator('b'),
66-
], errorText: customErrorMessage,);
63+
final OrValidator validator = OrValidator(
64+
<FormFieldValidator>[
65+
const EqualValidator('a'),
66+
const EqualValidator('b'),
67+
],
68+
errorText: customErrorMessage,
69+
);
6770
const String value = 'c';
6871

6972
// Act

0 commit comments

Comments
 (0)