forked from eatvio/eatvio_app
feat(dependencies): add rxdart package and improve string extension methods for better handling of empty strings and gender parsing
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import 'package:eatvio_app/features/cancel_plan_bottom_sheet/models/cancelation_model.dart';
|
||||
import 'package:eatvio_app/features/cancel_plan_bottom_sheet/repository/cancel_plan_repository.dart';
|
||||
import 'package:eatvio_app/features/cancel_plan_bottom_sheet/service/cancel_plan_service.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
|
||||
import 'cancel_plan_repository_test.mocks.dart';
|
||||
|
||||
@GenerateNiceMocks([MockSpec<CancelPlanService>()])
|
||||
void main() {
|
||||
group('CancelPlanRepository', () {
|
||||
late CancelPlanRepository repository;
|
||||
late MockCancelPlanService mockService;
|
||||
|
||||
setUp(() {
|
||||
mockService = MockCancelPlanService();
|
||||
repository = CancelPlanRepository(cancelService: mockService);
|
||||
});
|
||||
|
||||
test('cancelChosenPlan - успешная отмена плана без body', () async {
|
||||
const id = 1;
|
||||
|
||||
when(mockService.cancelChosenPlan(id: id, body: null))
|
||||
.thenAnswer((_) async => Future.value());
|
||||
|
||||
await repository.cancelChosenPlan(id: id, body: null);
|
||||
|
||||
verify(mockService.cancelChosenPlan(id: id, body: null)).called(1);
|
||||
});
|
||||
|
||||
test('cancelChosenPlan - успешная отмена плана с body', () async {
|
||||
const id = 1;
|
||||
final body = CancelationModel(
|
||||
description: 'Test reason',
|
||||
price: 1000,
|
||||
);
|
||||
|
||||
when(mockService.cancelChosenPlan(id: id, body: body))
|
||||
.thenAnswer((_) async => Future.value());
|
||||
|
||||
await repository.cancelChosenPlan(id: id, body: body);
|
||||
|
||||
verify(mockService.cancelChosenPlan(id: id, body: body)).called(1);
|
||||
});
|
||||
|
||||
test('cancelChosenPlan - пробрасывает исключение', () async {
|
||||
const id = 1;
|
||||
|
||||
when(mockService.cancelChosenPlan(id: id, body: null))
|
||||
.thenThrow(Exception('Ошибка отмены плана'));
|
||||
|
||||
expect(
|
||||
() => repository.cancelChosenPlan(id: id, body: null),
|
||||
throwsException,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user