Files
eatvio_app/test/features/feed/presentation/widgets/chip_group_test.dart
2025-12-25 12:56:38 +03:00

52 lines
1.6 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:eatvio_app/core/app_config.dart';
import 'package:eatvio_app/core/app_initializer.dart';
import 'package:eatvio_app/core/locator_service.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/feed/presentation/widgets/chip_group.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('ChipGroup smoke', () {
setUpAll(() async {
dotenv.loadFromString(envString: 'DEV_BASE_URL=http://localhost\nBASE_URL=http://localhost');
});
setUp(() async {
await sl.reset();
sl.registerLazySingleton<AppConfig>(() => AppConfig(buildType: AppBuildType.tests)..setBaseUrl('http://localhost'));
});
Widget wrap(Widget child) {
return MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(body: child),
);
}
testWidgets('renders chip group', (tester) async {
int selectedIndex = 0;
final chipsList = ['Все', 'Рецепты', 'Диеты'];
await tester.pumpWidget(
wrap(
ChipGroup(
selectedChipIndex: selectedIndex,
chipsLabelList: chipsList,
setSelectedChipIndex: (index) {
selectedIndex = index;
},
),
),
);
await tester.pumpAndSettle();
expect(find.byType(ChipGroup), findsOneWidget);
expect(find.text('Все'), findsOneWidget);
expect(find.text('Рецепты'), findsOneWidget);
expect(find.text('Диеты'), findsOneWidget);
});
});
}