forked from eatvio/eatvio_app
refactor: Corrected typo in MyRecipesCubit filename and updated related tests, widgets, services, and DI registrations.
This commit is contained in:
@@ -433,6 +433,7 @@ void main() {
|
||||
final tempFile = File('${Directory.systemTemp.path}/test_image.jpg');
|
||||
await tempFile.writeAsBytes([1, 2, 3]);
|
||||
cubit.replaceImage(tempFile);
|
||||
cubit.addIngredient(const i.Ingredient(name: 'Test Ingredient', unit: 'gr', portion: '100', productId: 1));
|
||||
cubit.replaceDescriptionInStep('Step 1 description', 0);
|
||||
|
||||
expect(cubit.validateAll(), true);
|
||||
|
||||
@@ -116,7 +116,7 @@ void main() {
|
||||
test('deleteRecipe - удаляет рецепт', () async {
|
||||
const slug = 'recipe-slug';
|
||||
|
||||
when(() => mockService.deleteRecipe(slug: slug)).thenAnswer((_) async => Future.value(mockHttpResponse));
|
||||
when(() => mockService.deleteRecipe(slug: slug)).thenAnswer((_) async => Future.value());
|
||||
|
||||
await repository.deleteRecipe(slug);
|
||||
|
||||
@@ -147,7 +147,7 @@ void main() {
|
||||
energyPerServing: 300,
|
||||
);
|
||||
|
||||
await repository.publishRecipe(recipe);
|
||||
expect(() => repository.publishRecipe(recipe), throwsException);
|
||||
|
||||
// Методы не должны вызываться, так как изображение отсутствует
|
||||
verifyNever(() => mockService.publishRecipe(formData: any(named: 'formData')));
|
||||
@@ -169,7 +169,7 @@ void main() {
|
||||
energyPerServing: 300,
|
||||
);
|
||||
|
||||
await repository.publishRecipe(recipe);
|
||||
expect(() => repository.publishRecipe(recipe), throwsException);
|
||||
|
||||
// Методы не должны вызываться, так как изображение пустое
|
||||
verifyNever(() => mockService.publishRecipe(formData: any(named: 'formData')));
|
||||
|
||||
@@ -9,6 +9,10 @@ import 'package:mockito/mockito.dart';
|
||||
|
||||
import 'recipe_service_test.mocks.dart';
|
||||
|
||||
import 'package:retrofit/retrofit.dart';
|
||||
|
||||
final mockHttpResponse = HttpResponse(null, Response(requestOptions: RequestOptions()));
|
||||
|
||||
@GenerateNiceMocks([MockSpec<CreateRecipeService>()])
|
||||
void main() {
|
||||
group('CreateRecipeService', () {
|
||||
@@ -77,7 +81,7 @@ void main() {
|
||||
final formData = FormData.fromMap({});
|
||||
|
||||
when(mockCreateRecipeService.publishRecipe(formData: formData))
|
||||
.thenAnswer((_) async => Future.value());
|
||||
.thenAnswer((_) async => Future.value(mockHttpResponse));
|
||||
|
||||
await mockCreateRecipeService.publishRecipe(formData: formData);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user