forked from eatvio/eatvio_app
fix: issue-1049, issue-1039, issue-1035, issue-1032, issue-995, issue-993
This commit is contained in:
@@ -156,6 +156,44 @@ void main() {
|
||||
expect(dietsCubit!.state.errorMessage, isNull);
|
||||
});
|
||||
|
||||
test('loadDiets - сбрасывает currentPage при повторной загрузке', () async {
|
||||
dietsCubit = DietsCubit(
|
||||
feedRepository: mockFeedRepository,
|
||||
dietsRepository: mockDietRepository,
|
||||
);
|
||||
|
||||
const dietsPagination = DietsPagination(
|
||||
data: [],
|
||||
links: Links(
|
||||
first: 'https://example.com?page=1',
|
||||
last: 'https://example.com?page=1',
|
||||
prev: null,
|
||||
next: null,
|
||||
),
|
||||
meta: Meta(
|
||||
currentPage: 1,
|
||||
from: null,
|
||||
lastPage: 1,
|
||||
links: [],
|
||||
perPage: 10,
|
||||
to: null,
|
||||
total: 0,
|
||||
),
|
||||
);
|
||||
|
||||
when(mockFeedRepository.getDiets(
|
||||
query: anyNamed('query'),
|
||||
types: anyNamed('types'),
|
||||
duration: anyNamed('duration'),
|
||||
sorting: anyNamed('sorting'),
|
||||
)).thenAnswer((_) async => dietsPagination);
|
||||
|
||||
dietsCubit!.currentPage = 4;
|
||||
await dietsCubit!.loadDiets();
|
||||
|
||||
expect(dietsCubit!.currentPage, 1);
|
||||
});
|
||||
|
||||
test('loadDiets - обработка ошибки', () async {
|
||||
dietsCubit = DietsCubit(
|
||||
feedRepository: mockFeedRepository,
|
||||
|
||||
@@ -131,6 +131,31 @@ void main() {
|
||||
expect(plansCubit!.state.errorMessage, isNull);
|
||||
});
|
||||
|
||||
test('loadPlans - сбрасывает currentPage при повторной загрузке', () async {
|
||||
plansCubit = PlansCubit(feedRepository: mockFeedRepository, planRepository: mockPlanRepository);
|
||||
|
||||
const plansPagination = PlanPaginationModel(
|
||||
data: [],
|
||||
links: Links(first: 'https://example.com?page=1', last: 'https://example.com?page=1', prev: null, next: null),
|
||||
meta: Meta(currentPage: 1, from: 1, lastPage: 1, links: [], perPage: 10, to: 1, total: 0),
|
||||
);
|
||||
|
||||
when(
|
||||
mockFeedRepository.getPlans(
|
||||
query: anyNamed('query'),
|
||||
types: anyNamed('types'),
|
||||
duration: anyNamed('duration'),
|
||||
minPrice: anyNamed('minPrice'),
|
||||
maxPrice: anyNamed('maxPrice'),
|
||||
),
|
||||
).thenAnswer((_) async => plansPagination);
|
||||
|
||||
plansCubit!.currentPage = 4;
|
||||
await plansCubit!.loadPlans();
|
||||
|
||||
expect(plansCubit!.currentPage, 1);
|
||||
});
|
||||
|
||||
test('loadPlans - обработка ошибки', () async {
|
||||
plansCubit = PlansCubit(feedRepository: mockFeedRepository, planRepository: mockPlanRepository);
|
||||
|
||||
|
||||
@@ -110,6 +110,18 @@ void main() {
|
||||
expect(recipesCubit!.state.errorMessage, isNull);
|
||||
});
|
||||
|
||||
test('loadRecipesList - сбрасывает currentPage при повторной загрузке', () async {
|
||||
recipesCubit = RecipesCubit(feedRepository: mockFeedRepository, recipeRepository: mockRecipeRepository, aboutRecipeRepository: mockAboutRecipeRepository);
|
||||
|
||||
when(mockFeedRepository.getRecipes(tags: anyNamed('tags'), query: anyNamed('query'))).thenAnswer((_) async => []);
|
||||
when(mockRecipeRepository.getRecipesTags()).thenAnswer((_) async => []);
|
||||
|
||||
recipesCubit!.currentPage = 4;
|
||||
await recipesCubit!.loadRecipesList();
|
||||
|
||||
expect(recipesCubit!.currentPage, 1);
|
||||
});
|
||||
|
||||
test('updateTags - добавляет и удаляет теги', () {
|
||||
recipesCubit = RecipesCubit(feedRepository: mockFeedRepository, recipeRepository: mockRecipeRepository, aboutRecipeRepository: mockAboutRecipeRepository);
|
||||
|
||||
|
||||
@@ -136,4 +136,19 @@ void main() {
|
||||
expect(find.byType(FeedScreen), findsOneWidget);
|
||||
});
|
||||
});
|
||||
|
||||
group('shouldReloadFeedAfterCreate', () {
|
||||
test('перезагружает ленту после публикации диеты или плана', () {
|
||||
expect(shouldReloadFeedAfterCreate(true), isTrue);
|
||||
});
|
||||
|
||||
test('перезагружает ленту после публикации рецепта', () {
|
||||
expect(shouldReloadFeedAfterCreate('active'), isTrue);
|
||||
});
|
||||
|
||||
test('не перезагружает ленту при отмене или черновике рецепта', () {
|
||||
expect(shouldReloadFeedAfterCreate(null), isFalse);
|
||||
expect(shouldReloadFeedAfterCreate('drafted'), isFalse);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user