forked from eatvio/eatvio_app
feat(tests): updated tests coverage to 66.5%
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user