forked from eatvio/eatvio_app
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user