forked from eatvio/eatvio_app
feat(tests): tests coverage 67.2
This commit is contained in:
@@ -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));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user