feat(tests): updated tests coverage to 66.5%

This commit is contained in:
misha
2026-01-14 18:47:11 +03:00
parent 497ff19cfa
commit 13ccf56df0
102 changed files with 10146 additions and 379 deletions

View File

@@ -120,5 +120,131 @@ void main() {
expect(cubit.state.wasSentSuccessfully, false);
});
test('complain - отправляет жалобу на plan', () async {
const slug = 'test-plan-slug';
when(() => mockRepository.sendPlanComplain(
slug: slug,
category: any(named: 'category'),
body: any(named: 'body'),
)).thenAnswer((_) async => {});
cubit.setContentTypeAndIdentifier(contentType: ComplainedContent.plan, slug: slug);
cubit.setCategory(ComplainType.spam);
await cubit.complain();
expect(cubit.state.wasSentSuccessfully, true);
verify(() => mockRepository.sendPlanComplain(
slug: slug,
category: any(named: 'category'),
body: any(named: 'body'),
)).called(1);
});
test('complain - отправляет жалобу на recipe', () async {
const slug = 'test-recipe-slug';
when(() => mockRepository.sendRecipeComplain(
slug: slug,
category: any(named: 'category'),
body: any(named: 'body'),
)).thenAnswer((_) async => {});
cubit.setContentTypeAndIdentifier(contentType: ComplainedContent.recipe, slug: slug);
cubit.setCategory(ComplainType.spam);
await cubit.complain();
expect(cubit.state.wasSentSuccessfully, true);
verify(() => mockRepository.sendRecipeComplain(
slug: slug,
category: any(named: 'category'),
body: any(named: 'body'),
)).called(1);
});
test('complain - отправляет жалобу на profile', () async {
const slug = 'test-profile-slug';
when(() => mockRepository.sendProfileComplain(
slug: slug,
category: any(named: 'category'),
body: any(named: 'body'),
)).thenAnswer((_) async => {});
cubit.setContentTypeAndIdentifier(contentType: ComplainedContent.profile, slug: slug);
cubit.setCategory(ComplainType.spam);
await cubit.complain();
expect(cubit.state.wasSentSuccessfully, true);
verify(() => mockRepository.sendProfileComplain(
slug: slug,
category: any(named: 'category'),
body: any(named: 'body'),
)).called(1);
});
test('complain - отправляет жалобу на posts', () async {
const id = 1;
when(() => mockRepository.sendBlogPostsComplain(
id: id,
category: any(named: 'category'),
body: any(named: 'body'),
)).thenAnswer((_) async => {});
cubit.setContentTypeAndIdentifier(contentType: ComplainedContent.posts, id: id);
cubit.setCategory(ComplainType.spam);
await cubit.complain();
expect(cubit.state.wasSentSuccessfully, true);
verify(() => mockRepository.sendBlogPostsComplain(
id: id,
category: any(named: 'category'),
body: any(named: 'body'),
)).called(1);
});
test('complain - отправляет жалобу на comment', () async {
const id = 1;
when(() => mockRepository.sendCommentComplain(
id: id,
category: any(named: 'category'),
body: any(named: 'body'),
)).thenAnswer((_) async => {});
cubit.setContentTypeAndIdentifier(contentType: ComplainedContent.comment, id: id);
cubit.setCategory(ComplainType.spam);
await cubit.complain();
expect(cubit.state.wasSentSuccessfully, true);
verify(() => mockRepository.sendCommentComplain(
id: id,
category: any(named: 'category'),
body: any(named: 'body'),
)).called(1);
});
test('complain - возвращает false если category null', () async {
cubit.setContentTypeAndIdentifier(contentType: ComplainedContent.diet, id: 1);
await cubit.complain();
expect(cubit.state.wasSentSuccessfully, false);
});
test('complain - возвращает false если contentType null', () async {
cubit.setCategory(ComplainType.spam);
await cubit.complain();
expect(cubit.state.wasSentSuccessfully, false);
});
});
}