forked from eatvio/eatvio_app
fix: issue-1049, issue-1039, issue-1035, issue-1032, issue-995, issue-993
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:eatvio_app/core/enums/complained_content.dart';
|
||||
import 'package:eatvio_app/features/complaining/models/complain_model.dart';
|
||||
import 'package:eatvio_app/features/complaining/presentation/complaining_bottom_sheet.dart';
|
||||
@@ -97,6 +99,7 @@ void main() {
|
||||
await cubit.complain();
|
||||
|
||||
expect(cubit.state.wasSentSuccessfully, true);
|
||||
expect(cubit.state.isLoading, false);
|
||||
verify(() => mockRepository.sendDietComplain(
|
||||
id: id,
|
||||
category: any(named: 'category'),
|
||||
@@ -104,6 +107,30 @@ void main() {
|
||||
)).called(1);
|
||||
});
|
||||
|
||||
test('complain - ставит isLoading на время запроса', () async {
|
||||
const id = 1;
|
||||
final completer = Completer<void>();
|
||||
|
||||
when(() => mockRepository.sendDietComplain(
|
||||
id: id,
|
||||
category: any(named: 'category'),
|
||||
body: any(named: 'body'),
|
||||
)).thenAnswer((_) => completer.future);
|
||||
|
||||
cubit.setContentTypeAndIdentifier(contentType: ComplainedContent.diet, id: id);
|
||||
cubit.setCategory(ComplainType.spam);
|
||||
|
||||
final future = cubit.complain();
|
||||
expect(cubit.state.isLoading, true);
|
||||
expect(cubit.state.wasSentSuccessfully, isNull);
|
||||
|
||||
completer.complete();
|
||||
await future;
|
||||
|
||||
expect(cubit.state.isLoading, false);
|
||||
expect(cubit.state.wasSentSuccessfully, true);
|
||||
});
|
||||
|
||||
test('complain - возвращает false при ошибке', () async {
|
||||
const id = 1;
|
||||
|
||||
@@ -119,6 +146,7 @@ void main() {
|
||||
await cubit.complain();
|
||||
|
||||
expect(cubit.state.wasSentSuccessfully, false);
|
||||
expect(cubit.state.isLoading, false);
|
||||
});
|
||||
|
||||
test('complain - отправляет жалобу на plan', () async {
|
||||
|
||||
Reference in New Issue
Block a user