feat(tests): tests coverage 67.2

This commit is contained in:
misha
2026-01-19 12:32:11 +03:00
parent 13ccf56df0
commit 44ede73ceb
20 changed files with 5084 additions and 409 deletions

View File

@@ -408,6 +408,52 @@ void main() {
expect(state.hasUnreadNotifications, false); // Все прочитаны
}
});
test('markNotificationsAsRead - не выполняет действие если state не loaded', () async {
when(mockNotificationsRepository.markNotificationsAsRead())
.thenAnswer((_) async => {});
await cubit.markNotificationsAsRead();
// Не должно вызывать репозиторий, так как state не loaded
verifyNever(mockNotificationsRepository.markNotificationsAsRead());
});
test('loadMoreNotifications - не выполняет действие если state не loaded', () async {
await cubit.loadMoreNotifications();
// Не должно вызывать репозиторий, так как state не loaded
verifyNever(mockNotificationsRepository.getNotifications(page: anyNamed('page')));
});
test('loadMoreNotifications - не загружает если isLoadingMore = true', () async {
final notifications = [
ChosenPlanStartedToClientNotification(
type: NotificationType.chosenPlanStartedToClientNotification,
planName: 'Plan 1',
planId: 1,
isRead: false,
createdAt: DateTime.now(),
),
];
when(mockNotificationsRepository.getNotifications(page: 1))
.thenAnswer((_) async => {
'notifications': notifications,
'pagination': {'current_page': 1, 'last_page': 2},
});
await cubit.getNotifications();
final firstState = cubit.state as NotificationsStateLoaded;
// Устанавливаем isLoadingMore в true
cubit.emit(firstState.copyWith(isLoadingMore: true));
await cubit.loadMoreNotifications();
// Не должно вызывать репозиторий, так как isLoadingMore = true
verifyNever(mockNotificationsRepository.getNotifications(page: 2));
});
});
}