forked from eatvio/eatvio_app
Merge remote-tracking branch 'upstream/main'
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/core/interceptors/token_interceptor.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/core/websockets/ws_manager.dart';
|
||||
import 'package:eatvio_app/core/locator_service.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
@@ -13,6 +15,8 @@ class MockErrorInterceptorHandler extends Mock implements ErrorInterceptorHandle
|
||||
|
||||
class MockResponse extends Mock implements Response {}
|
||||
|
||||
class MockWsManager extends Mock implements WsManager {}
|
||||
|
||||
class MockDioException extends Mock implements DioException {}
|
||||
|
||||
class FakeRequestOptions extends Fake implements RequestOptions {}
|
||||
@@ -31,6 +35,13 @@ void main() {
|
||||
|
||||
setUp(() async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
|
||||
final mockWsManager = MockWsManager();
|
||||
when(() => mockWsManager.clear()).thenAnswer((_) async {});
|
||||
|
||||
await sl.reset(); // Сбрасываем sl перед каждым тестом
|
||||
sl.registerSingleton<WsManager>(mockWsManager);
|
||||
|
||||
interceptor = TokenInterceptor();
|
||||
// Сбрасываем токен перед каждым тестом
|
||||
try {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -326,7 +326,7 @@ void main() {
|
||||
expect(find.byType(DietTypeChoiceWidget), findsOneWidget);
|
||||
expect(find.byType(DietImagePickerWidget), findsOneWidget);
|
||||
// Action buttons
|
||||
expect(find.byType(CustomOutlinedButton), findsNWidgets(3));
|
||||
expect(find.byType(CustomOutlinedButton), findsNWidgets(2));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ void main() {
|
||||
|
||||
// Assert
|
||||
expect(find.byType(MyDietsTab), findsOneWidget);
|
||||
expect(find.byType(AnimatedOptionButton), findsNWidgets(3));
|
||||
expect(find.byType(AnimatedOptionButton), findsNWidgets(2));
|
||||
});
|
||||
|
||||
testWidgets('should handle tab selection in MyDietsTab', (WidgetTester tester) async {
|
||||
@@ -119,7 +119,7 @@ void main() {
|
||||
|
||||
// Act - Find and tap the second tab
|
||||
final tabButtons = find.byType(AnimatedOptionButton);
|
||||
expect(tabButtons, findsNWidgets(3));
|
||||
expect(tabButtons, findsNWidgets(2));
|
||||
|
||||
// Tap the second tab (index 1)
|
||||
await tester.tap(tabButtons.at(1));
|
||||
@@ -221,7 +221,7 @@ void main() {
|
||||
|
||||
// Assert
|
||||
expect(find.byType(MyDietsTab), findsOneWidget);
|
||||
expect(find.byType(AnimatedOptionButton), findsNWidgets(3));
|
||||
expect(find.byType(AnimatedOptionButton), findsNWidgets(2));
|
||||
});
|
||||
|
||||
testWidgets('should handle MyDietsTab additionalOnTap callback', (WidgetTester tester) async {
|
||||
|
||||
Reference in New Issue
Block a user