forked from eatvio/eatvio_app
chore(version): update app version to 1.3.5+85 and improve test coverage reporting in CI
This commit is contained in:
@@ -2,12 +2,10 @@ import 'package:eatvio_app/features/registration_v2/models/registration_model.da
|
||||
import 'package:eatvio_app/features/registration_v2/repositories/registration_repository_v2.dart';
|
||||
import 'package:eatvio_app/features/registration_v2/services/registration_service_v2.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
|
||||
import 'registration_repository_v2_test.mocks.dart';
|
||||
class MockRegistrationServiceV2 extends Mock implements RegistrationServiceV2 {}
|
||||
|
||||
@GenerateMocks([RegistrationServiceV2])
|
||||
void main() {
|
||||
group('RegistrationRepositoryV2', () {
|
||||
late RegistrationRepositoryV2 repository;
|
||||
@@ -18,10 +16,11 @@ void main() {
|
||||
repository = RegistrationRepositoryV2(registrationService: mockService);
|
||||
});
|
||||
|
||||
test('register - успешная регистрация', () async {
|
||||
test('register - успешная регистрация возвращает токен', () async {
|
||||
const token = 'test-token-123';
|
||||
final registrationModel = RegistrationModel(
|
||||
firstName: 'John',
|
||||
lastName: 'Doe',
|
||||
firstName: 'Test',
|
||||
lastName: 'User',
|
||||
email: 'test@example.com',
|
||||
phone: '+1234567890',
|
||||
gender: 'male',
|
||||
@@ -33,20 +32,19 @@ void main() {
|
||||
birthday: '1990-01-01',
|
||||
);
|
||||
|
||||
const token = 'test-token';
|
||||
when(mockService.register(model: anyNamed('model')))
|
||||
when(() => mockService.register(model: any(named: 'model')))
|
||||
.thenAnswer((_) async => {'token': token});
|
||||
|
||||
final result = await repository.register(registrationModel: registrationModel);
|
||||
|
||||
expect(result, equals(token));
|
||||
verify(mockService.register(model: anyNamed('model'))).called(1);
|
||||
expect(result, token);
|
||||
verify(() => mockService.register(model: any(named: 'model'))).called(1);
|
||||
});
|
||||
|
||||
test('register - проброс ошибки', () async {
|
||||
test('register - возвращает null если токена нет', () async {
|
||||
final registrationModel = RegistrationModel(
|
||||
firstName: 'John',
|
||||
lastName: 'Doe',
|
||||
firstName: 'Test',
|
||||
lastName: 'User',
|
||||
email: 'test@example.com',
|
||||
phone: '+1234567890',
|
||||
gender: 'male',
|
||||
@@ -58,16 +56,33 @@ void main() {
|
||||
birthday: '1990-01-01',
|
||||
);
|
||||
|
||||
final error = Exception('Ошибка регистрации');
|
||||
when(mockService.register(model: anyNamed('model')))
|
||||
.thenThrow(error);
|
||||
when(() => mockService.register(model: any(named: 'model')))
|
||||
.thenAnswer((_) async => {});
|
||||
|
||||
expect(
|
||||
() => repository.register(registrationModel: registrationModel),
|
||||
throwsA(error),
|
||||
final result = await repository.register(registrationModel: registrationModel);
|
||||
|
||||
expect(result, null);
|
||||
});
|
||||
|
||||
test('register - пробрасывает ошибку', () async {
|
||||
final registrationModel = RegistrationModel(
|
||||
firstName: 'Test',
|
||||
lastName: 'User',
|
||||
email: 'test@example.com',
|
||||
phone: '+1234567890',
|
||||
gender: 'male',
|
||||
password: 'password123',
|
||||
confirmPassword: 'password123',
|
||||
weight: 70,
|
||||
height: 175,
|
||||
activityCoefficient: 1.5,
|
||||
birthday: '1990-01-01',
|
||||
);
|
||||
verify(mockService.register(model: anyNamed('model'))).called(1);
|
||||
|
||||
when(() => mockService.register(model: any(named: 'model')))
|
||||
.thenThrow(Exception('Error'));
|
||||
|
||||
expect(() => repository.register(registrationModel: registrationModel), throwsException);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user