forked from eatvio/eatvio_app
54 lines
2.2 KiB
Dart
54 lines
2.2 KiB
Dart
import 'package:eatvio_app/features/menu/models/notification_settings_model.dart';
|
|
import 'package:eatvio_app/features/menu/services/notification_settings_service.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:mockito/annotations.dart';
|
|
import 'package:mockito/mockito.dart';
|
|
import '../../../fixtures/menu_fixtures.dart';
|
|
import 'notification_settings_service_test.mocks.dart';
|
|
|
|
@GenerateNiceMocks([MockSpec<NotificationSettingsService>()])
|
|
void main() {
|
|
group('NotificationSettingsService', () {
|
|
late MockNotificationSettingsService mockNotificationSettingsService;
|
|
|
|
setUp(() {
|
|
mockNotificationSettingsService = MockNotificationSettingsService();
|
|
});
|
|
|
|
test('getNotificationSettings - возвращает настройки уведомлений', () async {
|
|
final expectedSettings = MenuFixtures.notificationSettingsModel();
|
|
|
|
when(mockNotificationSettingsService.getNotificationSettings())
|
|
.thenAnswer((_) async => expectedSettings);
|
|
|
|
final result = await mockNotificationSettingsService.getNotificationSettings();
|
|
|
|
expect(result, isA<NotificationSettingsModel>());
|
|
expect(result.newUpdatesNotification, true);
|
|
expect(result.isEmailNotificationsEnabled, true);
|
|
verify(mockNotificationSettingsService.getNotificationSettings()).called(1);
|
|
});
|
|
|
|
test('updateNotificationSettings - обновляет настройки уведомлений', () async {
|
|
final data = {
|
|
'new_updates_notification': false,
|
|
'weight_measurements_notification': true,
|
|
'is_email_notifications_enabled': true,
|
|
'is_push_notifications_enabled': false,
|
|
};
|
|
final expectedSettings = MenuFixtures.notificationSettingsUpdatedModel();
|
|
|
|
when(mockNotificationSettingsService.updateNotificationSettings(data: data))
|
|
.thenAnswer((_) async => expectedSettings);
|
|
|
|
final result = await mockNotificationSettingsService.updateNotificationSettings(data: data);
|
|
|
|
expect(result, isA<NotificationSettingsModel>());
|
|
expect(result.newUpdatesNotification, false);
|
|
expect(result.isPushNotificationsEnabled, false);
|
|
verify(mockNotificationSettingsService.updateNotificationSettings(data: data)).called(1);
|
|
});
|
|
});
|
|
}
|
|
|