test: add unit tests for ValidationUtils covering email, phone, URL, password, username, text, title, and description length validations, along with phone normalization and error message generation.

This commit is contained in:
mso7nueh
2026-01-29 16:01:18 +03:00
parent db6db89567
commit 843e1ce4dd

View File

@@ -30,6 +30,28 @@ void main() {
});
});
group('normalizePhone', () {
test('normalizes phone starting with +7', () {
expect(ValidationUtils.normalizePhone('+7 (915) 062 61 51'), '+79150626151');
});
test('normalizes phone starting with 8', () {
expect(ValidationUtils.normalizePhone('89150626151'), '+79150626151');
});
test('normalizes 10-digit phone', () {
expect(ValidationUtils.normalizePhone('9150626151'), '+79150626151');
});
test('returns empty string for empty input', () {
expect(ValidationUtils.normalizePhone(''), '');
});
test('returns empty string for input with no digits', () {
expect(ValidationUtils.normalizePhone('abc'), '');
});
});
group('isValidUrl', () {
test('returns true for valid URL', () {
expect(ValidationUtils.isValidUrl('https://example.com'), isTrue);