mirror of
https://github.com/immich-app/immich.git
synced 2025-01-06 11:56:46 +01:00
50 lines
1.1 KiB
Dart
50 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');
|
||
|
});
|
||
|
});
|
||
|
}
|