From 843e1ce4dd2439bd2bd4d93c55a439cb3530f954 Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Thu, 29 Jan 2026 16:01:18 +0300 Subject: [PATCH] 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. --- test/core/utils/validation_utils_test.dart | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/core/utils/validation_utils_test.dart b/test/core/utils/validation_utils_test.dart index e3f875a6..30c4adf1 100644 --- a/test/core/utils/validation_utils_test.dart +++ b/test/core/utils/validation_utils_test.dart @@ -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);