Initial commit

This commit is contained in:
admin1
2026-07-14 11:11:36 +08:00
commit 656499cf94
604 changed files with 119518 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:smplayer/core/contracts/trakt/trakt_ids.dart';
void main() {
test('fromJson 统一解析 Trakt 外部 ID', () {
final ids = TraktIds.fromJson({
'trakt': 1.0,
'imdb': 'tt123',
'tmdb': 2,
'tvdb': 3.0,
'slug': 'demo',
});
expect(ids.toJson(), {
'trakt': 1,
'imdb': 'tt123',
'tmdb': 2,
'tvdb': 3,
'slug': 'demo',
});
expect(TraktIds.fromJson(null).toJson(), isEmpty);
});
}
@@ -0,0 +1,27 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:smplayer/core/contracts/trakt/trakt_sync_job.dart';
void main() {
test('旧队列 JSON 的冗余字段可忽略且调度字段保留', () {
final job = TraktSyncJob.fromJson({
'id': 'job-1',
'type': 'scrobble_pause',
'body': {
'movie': {'title': 'Demo'},
},
'progress': 42.0,
'createdAt': '2026-01-01T00:00:00Z',
'updatedAt': '2026-01-02T00:00:00Z',
'lastError': 'transient',
'retryCount': 3,
'nextRetryAt': '2026-01-03T00:00:00Z',
'exhausted': false,
});
expect(job.type, TraktSyncJobType.scrobblePause);
expect(job.retryCount, 3);
expect(job.nextRetryAt, DateTime.utc(2026, 1, 3));
expect(job.toJson(), isNot(contains('progress')));
expect(job.toJson(), isNot(contains('lastError')));
});
}