feat(tests): menu, settings, remove icov, remove generated files from % tests

This commit is contained in:
mso7nueh
2025-11-27 08:18:23 +03:00
parent 2e57cd9519
commit 7df32dabd2
25 changed files with 1271 additions and 30783 deletions

View File

@@ -0,0 +1,68 @@
import 'package:eatvio_app/features/menu/presentation/bloc/menu_cubit/menu_cubit.dart';
import 'package:eatvio_app/features/menu/presentation/bloc/menu_cubit/menu_state.dart';
import 'package:eatvio_app/features/profile/repositories/profile_repository.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'menu_cubit_test.mocks.dart';
@GenerateNiceMocks([MockSpec<ProfileRepository>()])
void main() {
group('MenuCubit', () {
MenuCubit? menuCubit;
late MockProfileRepository mockProfileRepository;
setUp(() {
mockProfileRepository = MockProfileRepository();
});
tearDown(() async {
if (menuCubit != null && !menuCubit!.isClosed) {
await Future.delayed(const Duration(milliseconds: 100));
menuCubit!.close();
menuCubit = null;
}
});
test('начальное состояние - MenuState', () {
menuCubit = MenuCubit(mockProfileRepository);
expect(menuCubit!.state, isA<MenuState>());
});
test('makePassKey - успешно создает passKey', () async {
menuCubit = MenuCubit(mockProfileRepository);
const expectedPassKey = 'test-pass-key';
when(mockProfileRepository.getPassKey(
routeName: 'product_nutritional_value.index',
routeParams: {},
)).thenAnswer((_) async => expectedPassKey);
final result = await menuCubit!.makePassKey();
expect(result, expectedPassKey);
verify(mockProfileRepository.getPassKey(
routeName: 'product_nutritional_value.index',
routeParams: {},
)).called(1);
});
test('makePassKey - возвращает null при ошибке', () async {
menuCubit = MenuCubit(mockProfileRepository);
when(mockProfileRepository.getPassKey(
routeName: 'product_nutritional_value.index',
routeParams: {},
)).thenThrow(Exception('Ошибка получения passKey'));
final result = await menuCubit!.makePassKey();
expect(result, isNull);
verify(mockProfileRepository.getPassKey(
routeName: 'product_nutritional_value.index',
routeParams: {},
)).called(1);
});
});
}