Initial commit
This commit is contained in:
@@ -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')));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user