feat(tests): added services tests and fixtures

This commit is contained in:
misha
2025-12-11 15:53:35 +03:00
parent d1753e99f8
commit 070a3e39e7
65 changed files with 2092 additions and 1130 deletions

View File

@@ -0,0 +1,58 @@
import 'package:eatvio_app/features/complaining/models/complain_model.dart';
import 'package:eatvio_app/features/complaining/services/complaining_service.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'complaining_service_test.mocks.dart';
@GenerateNiceMocks([MockSpec<ComplainingService>()])
void main() {
group('ComplainingService', () {
late MockComplainingService mockComplainingService;
setUp(() {
mockComplainingService = MockComplainingService();
});
test('sendPlanComplain - отправляет жалобу на план', () async {
const slug = 'test-plan';
const category = 'spam';
const complainModel = ComplainModel(description: 'Test complaint', tags: []);
when(mockComplainingService.sendPlanComplain(slug: slug, category: category, body: complainModel))
.thenAnswer((_) async => Future.value());
await mockComplainingService.sendPlanComplain(slug: slug, category: category, body: complainModel);
verify(mockComplainingService.sendPlanComplain(slug: slug, category: category, body: complainModel)).called(1);
});
test('sendRecipeComplain - отправляет жалобу на рецепт', () async {
const slug = 'test-recipe';
const category = 'spam';
const complainModel = ComplainModel(description: 'Test complaint', tags: []);
when(mockComplainingService.sendRecipeComplain(slug: slug, category: category, body: complainModel))
.thenAnswer((_) async => Future.value());
await mockComplainingService.sendRecipeComplain(slug: slug, category: category, body: complainModel);
verify(mockComplainingService.sendRecipeComplain(slug: slug, category: category, body: complainModel)).called(1);
});
test('sendBlogPostsComplain - отправляет жалобу на пост блога', () async {
const id = 1;
const category = 'spam';
const complainModel = ComplainModel(description: 'Test complaint', tags: []);
when(mockComplainingService.sendBlogPostsComplain(id: id, category: category, body: complainModel))
.thenAnswer((_) async => Future.value());
await mockComplainingService.sendBlogPostsComplain(id: id, category: category, body: complainModel);
verify(mockComplainingService.sendBlogPostsComplain(id: id, category: category, body: complainModel)).called(1);
});
});
}