mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-11-21 20:00:49 +01:00
Rename the Dart package, Android and iOS identifiers, Rust crates, native libraries, and Discord plugin. Preserve legacy data readers and compatibility aliases. Update localized branding, documentation, artwork, build tooling, and release artifacts. Route Telegram release notifications to @mornyeupdates and link @mornyecommunity.
87 lines
2.3 KiB
Dart
87 lines
2.3 KiB
Dart
import 'dart:convert';
|
|
import 'dart:io';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:mornye/services/collection_restore_codec.dart';
|
|
|
|
void main() {
|
|
test(
|
|
'worker and streamed commands preserve the existing collection codec',
|
|
() async {
|
|
final fixture =
|
|
jsonDecode(
|
|
File(
|
|
'test/fixtures/collection_restore_contract.json',
|
|
).readAsStringSync(),
|
|
)
|
|
as Map<String, dynamic>;
|
|
final input = fixture['input'] as Map<String, dynamic>;
|
|
final now = fixture['now'] as String;
|
|
expect(
|
|
collectionRestoreCommands(input, now).toList(),
|
|
fixture['commands'],
|
|
);
|
|
expect(
|
|
await prepareCollectionRestoreCommands(input, now),
|
|
fixture['commands'],
|
|
);
|
|
final temporary = await Directory.systemTemp.createTemp(
|
|
'collection-codec-',
|
|
);
|
|
addTearDown(() => temporary.delete(recursive: true));
|
|
final path = '${temporary.path}/commands.ndjson';
|
|
expect(await writeCollectionRestoreCommands(path, input, now), 9);
|
|
expect(
|
|
(await File(path).readAsLines()).map(jsonDecode).toList(),
|
|
fixture['commands'],
|
|
);
|
|
},
|
|
);
|
|
|
|
test('empty or omitted categories produce an empty replacement', () async {
|
|
expect(await prepareCollectionRestoreCommands({}, 'now'), isEmpty);
|
|
expect(
|
|
await prepareCollectionRestoreCommands({
|
|
'wishlist': false,
|
|
'loved': <String, dynamic>{},
|
|
'playlists': [
|
|
null,
|
|
{'id': ''},
|
|
],
|
|
'favoriteArtists': [
|
|
{'key': ''},
|
|
],
|
|
}, 'now'),
|
|
isEmpty,
|
|
);
|
|
});
|
|
|
|
test(
|
|
'invalid typed fields still reject the restore before publication',
|
|
() async {
|
|
for (final input in <Map<String, dynamic>>[
|
|
{
|
|
'wishlist': [
|
|
{'key': 7, 'track': <String, dynamic>{}},
|
|
],
|
|
},
|
|
{
|
|
'playlists': [
|
|
{'id': 'p', 'coverImagePath': false},
|
|
],
|
|
},
|
|
{
|
|
'favoriteArtists': [
|
|
{'key': 'a', 'addedAt': 1},
|
|
],
|
|
},
|
|
]) {
|
|
await expectLater(
|
|
prepareCollectionRestoreCommands(input, 'now'),
|
|
throwsA(isA<TypeError>()),
|
|
);
|
|
}
|
|
},
|
|
);
|
|
}
|