// test/playlist_summary_test.dart import 'package:flutter_test/flutter_test.dart'; import 'package:qingting_player/models/playlist_summary.dart'; void main() { group('PlaylistSummary.fromRow', () { test('完整行解析', () { final s = PlaylistSummary.fromRow({ 'id': 'abc', 'name': '随手', 'song_count': 12, 'cover_path': '/data/artworks/x.jpg', 'updated_at': 1700000000, }); expect(s.id, 'abc'); expect(s.name, '随手'); expect(s.songCount, 12); expect(s.coverPath, '/data/artworks/x.jpg'); expect(s.isEmpty, isFalse); }); test('没有封面时 coverPath 为 null', () { final s = PlaylistSummary.fromRow({ 'id': 'abc', 'name': '车用', 'song_count': 3, 'cover_path': '', }); expect(s.coverPath, isNull); expect(s.songCount, 3); }); test('空歌单 isEmpty', () { final s = PlaylistSummary.fromRow({ 'id': 'x', 'name': '空', 'song_count': 0, }); expect(s.isEmpty, isTrue); expect(s.coverPath, isNull); }); test('字段缺失时不崩', () { final s = PlaylistSummary.fromRow({}); expect(s.id, ''); expect(s.name, ''); expect(s.songCount, 0); expect(s.isEmpty, isTrue); }); }); }