forked from eatvio/eatvio_app
feat(tests): fixed feed tests failing and added tests for my_diets, my_plans and recipes
This commit is contained in:
@@ -0,0 +1,244 @@
|
||||
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
|
||||
import 'package:eatvio_app/features/feed/models/recipes_model.dart';
|
||||
import 'package:eatvio_app/features/recipe/models/my_recipe_model.dart';
|
||||
import 'package:eatvio_app/features/recipe/presentation/cubit/my_recipes_cubit/my_recieps_cubit.dart';
|
||||
import 'package:eatvio_app/features/recipe/presentation/cubit/my_recipes_cubit/my_recipes_state.dart';
|
||||
import 'package:eatvio_app/features/recipe/repositories/about_recipe_repository.dart';
|
||||
import 'package:eatvio_app/features/recipe/repositories/my_recipes_repository.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'my_recipes_cubit_test.mocks.dart';
|
||||
|
||||
@GenerateNiceMocks([
|
||||
MockSpec<MyRecipesRepository>(),
|
||||
MockSpec<AboutRecipeRepository>(),
|
||||
])
|
||||
void main() {
|
||||
group('MyRecipesCubit', () {
|
||||
MyRecipesCubit? myRecipesCubit;
|
||||
late MockMyRecipesRepository mockMyRecipesRepository;
|
||||
late MockAboutRecipeRepository mockAboutRecipeRepository;
|
||||
|
||||
final testActiveRecipe = MyRecipeModel(
|
||||
id: 1,
|
||||
image: 'https://someurl.com/img.jpg',
|
||||
state: 'active',
|
||||
cookingTime: 30,
|
||||
activeCookingTime: 20,
|
||||
description: 'Test recipe description',
|
||||
steps: [
|
||||
const Step(image: 'https://someurl.com/step1.jpg', description: 'Step 1 description'),
|
||||
],
|
||||
videoUrl: 'https://someurl.com/video.mp4',
|
||||
title: 'Test Recipe',
|
||||
slug: 'test-recipe',
|
||||
calories: 250.0,
|
||||
likesCount: 5,
|
||||
viewsCount: 10,
|
||||
);
|
||||
|
||||
final testArchivedRecipe = MyRecipeModel(
|
||||
id: 2,
|
||||
image: 'https://someurl.com/img2.jpg',
|
||||
state: 'archived',
|
||||
cookingTime: 45,
|
||||
activeCookingTime: 30,
|
||||
description: 'Archived recipe description',
|
||||
steps: null,
|
||||
videoUrl: null,
|
||||
title: 'Archived Recipe',
|
||||
slug: 'archived-recipe',
|
||||
calories: 350.0,
|
||||
likesCount: 8,
|
||||
viewsCount: 15,
|
||||
);
|
||||
|
||||
final testRecipe = Recipe(
|
||||
id: 1,
|
||||
image: 'https://someurl.com/img.jpg',
|
||||
state: 'published',
|
||||
cookingTime: 30,
|
||||
activeCookingTime: 20,
|
||||
ingredients: null,
|
||||
description: 'Test recipe description',
|
||||
steps: [
|
||||
const Step(image: 'https://someurl.com/step1.jpg', description: 'Step 1 description'),
|
||||
],
|
||||
videoUrl: 'https://someurl.com/video.mp4',
|
||||
createdAt: DateTime.now(),
|
||||
updatedAt: DateTime.now(),
|
||||
title: 'Test Recipe',
|
||||
type: 'recipe',
|
||||
slug: 'test-recipe',
|
||||
commentsCount: 5,
|
||||
wasLikedByMe: false,
|
||||
isFavorite: false,
|
||||
calories: 250.0,
|
||||
servings: 1,
|
||||
likesCount: 5,
|
||||
viewsCount: 10,
|
||||
tags: [],
|
||||
author: const Author(authorSlug: '', authorName: '', authorProfileIcon: '', authorIsMe: false),
|
||||
);
|
||||
|
||||
setUp(() {
|
||||
mockMyRecipesRepository = MockMyRecipesRepository();
|
||||
mockAboutRecipeRepository = MockAboutRecipeRepository();
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
if (myRecipesCubit != null && !myRecipesCubit!.isClosed) {
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
myRecipesCubit!.close();
|
||||
myRecipesCubit = null;
|
||||
}
|
||||
});
|
||||
|
||||
test('начальное состояние - loading', () {
|
||||
myRecipesCubit = MyRecipesCubit(
|
||||
myRecipesRepository: mockMyRecipesRepository,
|
||||
aboutRecipeRepository: mockAboutRecipeRepository,
|
||||
);
|
||||
expect(myRecipesCubit!.state, isA<MyRecipesStateLoading>());
|
||||
});
|
||||
|
||||
test('getMyRecipes - загружает активные рецепты', () async {
|
||||
myRecipesCubit = MyRecipesCubit(
|
||||
myRecipesRepository: mockMyRecipesRepository,
|
||||
aboutRecipeRepository: mockAboutRecipeRepository,
|
||||
);
|
||||
|
||||
when(mockMyRecipesRepository.getMyRecipes()).thenAnswer(
|
||||
(_) async => [testActiveRecipe, testArchivedRecipe],
|
||||
);
|
||||
|
||||
await myRecipesCubit!.getMyRecipes();
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
|
||||
expect(myRecipesCubit!.state, isA<MyRecipesStateLoaded>());
|
||||
final loadedState = myRecipesCubit!.state as MyRecipesStateLoaded;
|
||||
expect(loadedState.recipes.length, 1);
|
||||
expect(loadedState.recipes.first.state, 'active');
|
||||
expect(loadedState.selectedState, 'active');
|
||||
});
|
||||
|
||||
test('getMyRecipes - обрабатывает ошибку', () async {
|
||||
myRecipesCubit = MyRecipesCubit(
|
||||
myRecipesRepository: mockMyRecipesRepository,
|
||||
aboutRecipeRepository: mockAboutRecipeRepository,
|
||||
);
|
||||
|
||||
when(mockMyRecipesRepository.getMyRecipes()).thenThrow(Exception('Network error'));
|
||||
|
||||
await myRecipesCubit!.getMyRecipes();
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
|
||||
expect(myRecipesCubit!.state, isA<MyRecipesStateError>());
|
||||
});
|
||||
|
||||
test('setActiveState - устанавливает активное состояние', () async {
|
||||
myRecipesCubit = MyRecipesCubit(
|
||||
myRecipesRepository: mockMyRecipesRepository,
|
||||
aboutRecipeRepository: mockAboutRecipeRepository,
|
||||
);
|
||||
|
||||
when(mockMyRecipesRepository.getMyRecipes()).thenAnswer(
|
||||
(_) async => [testActiveRecipe, testArchivedRecipe],
|
||||
);
|
||||
|
||||
await myRecipesCubit!.setActiveState();
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
|
||||
expect(myRecipesCubit!.state, isA<MyRecipesStateLoaded>());
|
||||
final loadedState = myRecipesCubit!.state as MyRecipesStateLoaded;
|
||||
expect(loadedState.recipes.length, 1);
|
||||
expect(loadedState.recipes.first.state, 'active');
|
||||
expect(loadedState.selectedState, 'active');
|
||||
});
|
||||
|
||||
test('setActiveState - обрабатывает ошибку', () async {
|
||||
myRecipesCubit = MyRecipesCubit(
|
||||
myRecipesRepository: mockMyRecipesRepository,
|
||||
aboutRecipeRepository: mockAboutRecipeRepository,
|
||||
);
|
||||
|
||||
when(mockMyRecipesRepository.getMyRecipes()).thenThrow(Exception('Network error'));
|
||||
|
||||
await myRecipesCubit!.setActiveState();
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
|
||||
expect(myRecipesCubit!.state, isA<MyRecipesStateError>());
|
||||
});
|
||||
|
||||
test('setArchivedState - устанавливает архивное состояние', () async {
|
||||
myRecipesCubit = MyRecipesCubit(
|
||||
myRecipesRepository: mockMyRecipesRepository,
|
||||
aboutRecipeRepository: mockAboutRecipeRepository,
|
||||
);
|
||||
|
||||
when(mockMyRecipesRepository.getMyRecipes()).thenAnswer(
|
||||
(_) async => [testActiveRecipe, testArchivedRecipe],
|
||||
);
|
||||
|
||||
await myRecipesCubit!.setArchivedState();
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
|
||||
expect(myRecipesCubit!.state, isA<MyRecipesStateLoaded>());
|
||||
final loadedState = myRecipesCubit!.state as MyRecipesStateLoaded;
|
||||
expect(loadedState.recipes.length, 1);
|
||||
expect(loadedState.recipes.first.state, 'archived');
|
||||
expect(loadedState.selectedState, 'archived');
|
||||
});
|
||||
|
||||
test('setArchivedState - обрабатывает ошибку', () async {
|
||||
myRecipesCubit = MyRecipesCubit(
|
||||
myRecipesRepository: mockMyRecipesRepository,
|
||||
aboutRecipeRepository: mockAboutRecipeRepository,
|
||||
);
|
||||
|
||||
when(mockMyRecipesRepository.getMyRecipes()).thenThrow(Exception('Network error'));
|
||||
|
||||
await myRecipesCubit!.setArchivedState();
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
|
||||
expect(myRecipesCubit!.state, isA<MyRecipesStateError>());
|
||||
});
|
||||
|
||||
test('getRecipeById - получает рецепт по slug', () async {
|
||||
myRecipesCubit = MyRecipesCubit(
|
||||
myRecipesRepository: mockMyRecipesRepository,
|
||||
aboutRecipeRepository: mockAboutRecipeRepository,
|
||||
);
|
||||
|
||||
when(mockAboutRecipeRepository.getRecipe('test-recipe')).thenAnswer((_) async => testRecipe);
|
||||
|
||||
final result = await myRecipesCubit!.getRecipeById('test-recipe');
|
||||
|
||||
expect(result, isA<Recipe>());
|
||||
expect(result.id, 1);
|
||||
expect(result.slug, 'test-recipe');
|
||||
verify(mockAboutRecipeRepository.getRecipe('test-recipe')).called(1);
|
||||
});
|
||||
|
||||
test('getMyRecipes - фильтрует только активные рецепты', () async {
|
||||
myRecipesCubit = MyRecipesCubit(
|
||||
myRecipesRepository: mockMyRecipesRepository,
|
||||
aboutRecipeRepository: mockAboutRecipeRepository,
|
||||
);
|
||||
|
||||
when(mockMyRecipesRepository.getMyRecipes()).thenAnswer(
|
||||
(_) async => [testActiveRecipe, testArchivedRecipe, testActiveRecipe.copyWith(id: 3)],
|
||||
);
|
||||
|
||||
await myRecipesCubit!.getMyRecipes();
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
|
||||
expect(myRecipesCubit!.state, isA<MyRecipesStateLoaded>());
|
||||
final loadedState = myRecipesCubit!.state as MyRecipesStateLoaded;
|
||||
expect(loadedState.recipes.length, 2);
|
||||
expect(loadedState.recipes.every((r) => r.state == 'active'), true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,278 @@
|
||||
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/core/widgets/animated_option_button.dart';
|
||||
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
|
||||
import 'package:eatvio_app/features/feed/models/recipes_model.dart' as recipes;
|
||||
import 'package:eatvio_app/features/recipe/models/my_recipe_model.dart';
|
||||
import 'package:eatvio_app/features/recipe/presentation/cubit/my_recipes_cubit/my_recieps_cubit.dart';
|
||||
import 'package:eatvio_app/features/recipe/presentation/cubit/my_recipes_cubit/my_recipes_state.dart';
|
||||
import 'package:eatvio_app/features/recipe/presentation/widgets/my_recipe_widget.dart';
|
||||
import 'package:eatvio_app/features/recipe/presentation/widgets/my_recipes_tab.dart';
|
||||
import 'package:eatvio_app/features/recipe/repositories/about_recipe_repository.dart';
|
||||
import 'package:eatvio_app/features/recipe/repositories/my_recipes_repository.dart';
|
||||
import 'package:eatvio_app/generated/l10n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_portal/flutter_portal.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
|
||||
import 'basic_widget_test.mocks.dart';
|
||||
|
||||
@GenerateNiceMocks([MockSpec<MyRecipesRepository>(), MockSpec<AboutRecipeRepository>()])
|
||||
void main() {
|
||||
group('MyRecipes Basic Widget Tests', () {
|
||||
late MockMyRecipesRepository mockMyRecipesRepository;
|
||||
late MockAboutRecipeRepository mockAboutRecipeRepository;
|
||||
late MyRecipesCubit myRecipesCubit;
|
||||
|
||||
const testRecipe = MyRecipeModel(
|
||||
id: 1,
|
||||
image: 'test-image.jpg',
|
||||
state: 'active',
|
||||
cookingTime: 30,
|
||||
activeCookingTime: 20,
|
||||
description: 'Test recipe description',
|
||||
steps: [
|
||||
recipes.Step(image: 'https://someurl.com/step1.jpg', description: 'Step 1 description'),
|
||||
recipes.Step(image: 'https://someurl.com/step2.jpg', description: 'Step 2 description'),
|
||||
],
|
||||
videoUrl: 'https://someurl.com/video.mp4',
|
||||
title: 'Test Recipe',
|
||||
slug: 'test-recipe',
|
||||
calories: 250.0,
|
||||
likesCount: 5,
|
||||
viewsCount: 10,
|
||||
);
|
||||
|
||||
setUp(() async {
|
||||
await sl.reset();
|
||||
dotenv.loadFromString(envString: 'DEV_BASE_URL=http://localhost\nBASE_URL=http://localhost');
|
||||
mockMyRecipesRepository = MockMyRecipesRepository();
|
||||
mockAboutRecipeRepository = MockAboutRecipeRepository();
|
||||
myRecipesCubit = MyRecipesCubit(myRecipesRepository: mockMyRecipesRepository, aboutRecipeRepository: mockAboutRecipeRepository);
|
||||
sl.registerLazySingleton<AppConfig>(() => AppConfig(buildType: AppBuildType.tests)..setBaseUrl('http://localhost'));
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
if (!myRecipesCubit.isClosed) {
|
||||
myRecipesCubit.close();
|
||||
}
|
||||
});
|
||||
|
||||
Widget createTestWidget(Widget child, {bool wrapInScaffold = true}) {
|
||||
final widget = BlocProvider<MyRecipesCubit>(
|
||||
create: (context) => myRecipesCubit,
|
||||
child: Portal(
|
||||
child: wrapInScaffold ? Scaffold(body: SingleChildScrollView(child: child)) : SizedBox(width: 800, height: 600, child: child),
|
||||
),
|
||||
);
|
||||
return MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
localizationsDelegates: const [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: const [Locale('ru')],
|
||||
home: widget,
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('should create MyRecipesCubit successfully', (WidgetTester tester) async {
|
||||
// Arrange & Act
|
||||
final cubit = MyRecipesCubit(myRecipesRepository: mockMyRecipesRepository, aboutRecipeRepository: mockAboutRecipeRepository);
|
||||
|
||||
// Assert
|
||||
expect(cubit, isA<MyRecipesCubit>());
|
||||
expect(cubit.state, isA<MyRecipesStateLoading>());
|
||||
|
||||
cubit.close();
|
||||
});
|
||||
|
||||
testWidgets('should display MyRecipesTab with all tabs', (WidgetTester tester) async {
|
||||
// Arrange
|
||||
const widget = MyRecipesTab();
|
||||
|
||||
// Act
|
||||
await tester.pumpWidget(createTestWidget(widget));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Assert
|
||||
expect(find.byType(MyRecipesTab), findsOneWidget);
|
||||
expect(find.byType(AnimatedOptionButton), findsNWidgets(2));
|
||||
});
|
||||
|
||||
testWidgets('should handle tab selection in MyRecipesTab', (WidgetTester tester) async {
|
||||
// Arrange
|
||||
bool callbackCalled = false;
|
||||
final widget = MyRecipesTab(
|
||||
additionalOnTap: () {
|
||||
callbackCalled = true;
|
||||
},
|
||||
);
|
||||
|
||||
await tester.pumpWidget(createTestWidget(widget));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Act
|
||||
final tabButtons = find.byType(AnimatedOptionButton);
|
||||
expect(tabButtons, findsNWidgets(2));
|
||||
|
||||
await tester.tap(tabButtons.at(0));
|
||||
await tester.pump();
|
||||
|
||||
// Assert
|
||||
expect(callbackCalled, true);
|
||||
});
|
||||
|
||||
testWidgets('should display MyRecipeWidget with recipe title', (WidgetTester tester) async {
|
||||
// Arrange
|
||||
myRecipesCubit.emit(const MyRecipesState.loaded(recipes: [testRecipe], selectedState: 'active'));
|
||||
const widget = MyRecipeWidget(recipe: testRecipe);
|
||||
|
||||
// Act
|
||||
await tester.pumpWidget(createTestWidget(widget));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
// Assert
|
||||
expect(find.text('Test Recipe'), findsOneWidget);
|
||||
expect(find.byType(MyRecipeWidget), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should display MyRecipeWidget with description when description is present', (WidgetTester tester) async {
|
||||
// Arrange
|
||||
myRecipesCubit.emit(const MyRecipesState.loaded(recipes: [testRecipe], selectedState: 'active'));
|
||||
const widget = MyRecipeWidget(recipe: testRecipe);
|
||||
|
||||
// Act
|
||||
await tester.pumpWidget(createTestWidget(widget));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
// Assert
|
||||
expect(find.text('Test Recipe'), findsOneWidget);
|
||||
expect(find.byType(MyRecipeWidget), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should display MyRecipeWidget buttons', (WidgetTester tester) async {
|
||||
// Arrange
|
||||
myRecipesCubit.emit(const MyRecipesState.loaded(recipes: [testRecipe], selectedState: 'active'));
|
||||
const widget = MyRecipeWidget(recipe: testRecipe);
|
||||
|
||||
// Act
|
||||
await tester.pumpWidget(createTestWidget(widget));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
// Assert
|
||||
expect(find.byType(MyRecipeWidget), findsOneWidget);
|
||||
expect(find.byType(CustomOutlinedButton), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets('should display MyRecipeWidget with cooking time', (WidgetTester tester) async {
|
||||
// Arrange
|
||||
myRecipesCubit.emit(const MyRecipesState.loaded(recipes: [testRecipe], selectedState: 'active'));
|
||||
const widget = MyRecipeWidget(recipe: testRecipe);
|
||||
|
||||
// Act
|
||||
await tester.pumpWidget(createTestWidget(widget));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
// Assert
|
||||
expect(find.byType(MyRecipeWidget), findsOneWidget);
|
||||
expect(find.text('Test Recipe'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should display MyRecipeWidget with steps count', (WidgetTester tester) async {
|
||||
// Arrange
|
||||
myRecipesCubit.emit(const MyRecipesState.loaded(recipes: [testRecipe], selectedState: 'active'));
|
||||
const widget = MyRecipeWidget(recipe: testRecipe);
|
||||
|
||||
// Act
|
||||
await tester.pumpWidget(createTestWidget(widget));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
// Assert
|
||||
expect(find.byType(MyRecipeWidget), findsOneWidget);
|
||||
expect(find.text('Test Recipe'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should display MyRecipeWidget with calories', (WidgetTester tester) async {
|
||||
// Arrange
|
||||
myRecipesCubit.emit(const MyRecipesState.loaded(recipes: [testRecipe], selectedState: 'active'));
|
||||
const widget = MyRecipeWidget(recipe: testRecipe);
|
||||
|
||||
// Act
|
||||
await tester.pumpWidget(createTestWidget(widget));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
// Assert
|
||||
expect(find.byType(MyRecipeWidget), findsOneWidget);
|
||||
expect(find.text('Test Recipe'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should display MyRecipeWidget with null steps', (WidgetTester tester) async {
|
||||
// Arrange
|
||||
myRecipesCubit.emit(const MyRecipesState.loaded(recipes: [testRecipe], selectedState: 'active'));
|
||||
final recipeWithoutSteps = testRecipe.copyWith(steps: null);
|
||||
final widget = MyRecipeWidget(recipe: recipeWithoutSteps);
|
||||
|
||||
// Act
|
||||
await tester.pumpWidget(createTestWidget(widget));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
// Assert
|
||||
expect(find.byType(MyRecipeWidget), findsOneWidget);
|
||||
expect(find.text('Test Recipe'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should display MyRecipeWidget structure correctly', (WidgetTester tester) async {
|
||||
// Arrange
|
||||
myRecipesCubit.emit(const MyRecipesState.loaded(recipes: [testRecipe], selectedState: 'active'));
|
||||
const widget = MyRecipeWidget(recipe: testRecipe);
|
||||
|
||||
// Act
|
||||
await tester.pumpWidget(createTestWidget(widget));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
// Assert
|
||||
expect(find.byType(MyRecipeWidget), findsOneWidget);
|
||||
expect(find.text('Test Recipe'), findsOneWidget);
|
||||
expect(find.byType(CustomOutlinedButton), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets('should display MyRecipesTab structure correctly', (WidgetTester tester) async {
|
||||
// Arrange
|
||||
const widget = MyRecipesTab();
|
||||
|
||||
// Act
|
||||
await tester.pumpWidget(createTestWidget(widget));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Assert
|
||||
expect(find.byType(MyRecipesTab), findsOneWidget);
|
||||
expect(find.byType(AnimatedOptionButton), findsNWidgets(2));
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user