1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-04 02:46:47 +01:00
immich/mobile/test/modules/utils/openapi_patching_test.dart
Alex ebecb60f39
feat: user's features preferences (#12099)
* feat: metadata in UserPreference

* feat: web metadata settings

* feat: web metadata settings

* fix: typo

* patch openapi

* fix: missing translation key

* new organization of preference strucutre

* feature settings on web

* localization

* added and used feature settings

* add default value to response dto

* patch openapi

* format en.json file

* implement helper method

* use tags preference logic

* Fix logic bug and add tests

* fix preference can be null in detail panel
2024-08-29 14:29:04 -05:00

49 lines
1.1 KiB
Dart

import 'dart:convert';
import 'package:flutter_test/flutter_test.dart';
import 'package:openapi/api.dart';
import 'package:immich_mobile/utils/openapi_patching.dart';
void main() {
group('Test OpenApi Patching', () {
test('upgradeDto', () {
dynamic value;
String targetType;
targetType = 'UserPreferencesResponseDto';
value = jsonDecode("""
{
"download": {
"archiveSize": 4294967296,
"includeEmbeddedVideos": false
}
}
""");
upgradeDto(value, targetType);
expect(value['tags'], TagsResponse().toJson());
expect(value['download']['includeEmbeddedVideos'], false);
});
test('addDefault', () {
dynamic value = jsonDecode("""
{
"download": {
"archiveSize": 4294967296,
"includeEmbeddedVideos": false
}
}
""");
String keys = 'download.unknownKey';
dynamic defaultValue = 69420;
addDefault(value, keys, defaultValue);
expect(value['download']['unknownKey'], 69420);
keys = 'alpha.beta';
defaultValue = 'gamma';
addDefault(value, keys, defaultValue);
expect(value['alpha']['beta'], 'gamma');
});
});
}