forked from eatvio/eatvio_app
61 lines
1.9 KiB
Dart
61 lines
1.9 KiB
Dart
import 'package:eatvio_app/features/settings/models/profile_settings_model.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
group('ProfileSettingsModel', () {
|
|
test('fromJson parses all fields correctly', () {
|
|
final json = {
|
|
'new_updates_notifications': true,
|
|
'diary_reminder_notifications': {'enabled': true},
|
|
'is_mood_fillable': true,
|
|
'is_bedtime_fillable': false,
|
|
'is_public_profile': true,
|
|
};
|
|
|
|
final model = ProfileSettingsModel.fromJson(json);
|
|
|
|
expect(model.newUpdatesNotifications, isTrue);
|
|
expect(model.diaryReminderNotifications, isNotNull);
|
|
expect(model.isMoodFillable, isTrue);
|
|
expect(model.isBedtimeFillable, isFalse);
|
|
expect(model.isPublicProfile, isTrue);
|
|
});
|
|
|
|
test('fromJson handles different notification types', () {
|
|
final json = {
|
|
'new_updates_notifications': false,
|
|
'diary_reminder_notifications': null,
|
|
'is_mood_fillable': false,
|
|
'is_bedtime_fillable': true,
|
|
'is_public_profile': false,
|
|
};
|
|
|
|
final model = ProfileSettingsModel.fromJson(json);
|
|
|
|
expect(model.newUpdatesNotifications, isFalse);
|
|
expect(model.isMoodFillable, isFalse);
|
|
expect(model.isBedtimeFillable, isTrue);
|
|
expect(model.isPublicProfile, isFalse);
|
|
});
|
|
|
|
test('toJson serializes all fields correctly', () {
|
|
const model = ProfileSettingsModel(
|
|
newUpdatesNotifications: true,
|
|
diaryReminderNotifications: {'enabled': true},
|
|
isMoodFillable: true,
|
|
isBedtimeFillable: false,
|
|
isPublicProfile: true,
|
|
);
|
|
|
|
final json = model.toJson();
|
|
|
|
expect(json['new_updates_notifications'], isTrue);
|
|
expect(json.containsKey('diary_reminder_notifications'), isTrue);
|
|
expect(json['is_mood_fillable'], isTrue);
|
|
expect(json['is_bedtime_fillable'], isFalse);
|
|
expect(json['is_public_profile'], isTrue);
|
|
});
|
|
});
|
|
}
|
|
|