forked from eatvio/eatvio_app
feat(UGPC): issue-777
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import 'package:eatvio_app/features/create_plan/presentation/cubit/create_plan_cubit.dart';
|
||||
import 'package:eatvio_app/features/create_plan/repositories/create_plan_repository.dart';
|
||||
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
|
||||
import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart';
|
||||
import 'package:flutter_image_compress/flutter_image_compress.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
@@ -703,6 +705,51 @@ void main() {
|
||||
expect(cubit.state.planCreated, false);
|
||||
});
|
||||
|
||||
test('loadExisting заполняет форму и обновляет существующий план', () async {
|
||||
const plan = PlanModel(
|
||||
id: 7,
|
||||
slug: 'test-plan',
|
||||
name: 'Test Plan',
|
||||
image: 'cover.jpg',
|
||||
duration: 14,
|
||||
state: 'active',
|
||||
type: PlanType(fit: true, slim: true, behavior: false, wellness: false),
|
||||
details: 'Описание плана',
|
||||
packetsCount: 1,
|
||||
packet1Options: PacketOptions(
|
||||
items: ['Консультации'],
|
||||
price: 1500,
|
||||
short: 'Базовый',
|
||||
description: 'Описание опции',
|
||||
hasPersonalDiet: false,
|
||||
),
|
||||
author: Author(authorSlug: 'author', authorName: 'Author', authorProfileIcon: 'icon.jpg', authorIsMe: true),
|
||||
totalLikes: 0,
|
||||
totalViews: 0,
|
||||
totalComments: 0,
|
||||
isFavorite: false,
|
||||
minPriceOfOptions: 1500,
|
||||
maxPriceOfOptions: 1500,
|
||||
wasLikedByMe: false,
|
||||
);
|
||||
|
||||
when(repository.updatePublishedPlan(slug: anyNamed('slug'), model: anyNamed('model'))).thenAnswer((_) async {});
|
||||
|
||||
cubit.loadExisting(plan);
|
||||
expect(cubit.sourcePlan?.slug, 'test-plan');
|
||||
expect(cubit.state.planData.name, 'Test Plan');
|
||||
expect(cubit.state.planData.duration, 14);
|
||||
expect(cubit.state.durationIndex, 1);
|
||||
expect(cubit.state.planData.type, [true, true, false, false]);
|
||||
expect(cubit.validateImage(), true);
|
||||
|
||||
await cubit.publishPlan();
|
||||
|
||||
verify(repository.updatePublishedPlan(slug: 'test-plan', model: anyNamed('model'))).called(1);
|
||||
verifyNever(repository.createPlan(model: anyNamed('model')));
|
||||
expect(cubit.state.planCreated, true);
|
||||
});
|
||||
|
||||
test('setPlanType - валидирует тип когда хотя бы один выбран', () {
|
||||
cubit.setPlanType([true, false, false, false]);
|
||||
expect(cubit.state.validationState.typeHasError, false);
|
||||
|
||||
Reference in New Issue
Block a user