fix(profile): 修复我的收藏与观看历史列表不显示

This commit is contained in:
Zhou Weidong authored and trae-solo-agent committed 2026-10-22 13:09:55 +08:00
1 parent f2ae0c70b6
commit a48433f01d
6 files changed
+202 -12

No files matched your search

+59
View File
@@ -0,0 +1,59 @@
// Author: fruit.com.cn
import 'package:flutter_test/flutter_test.dart';
import 'package:fruitshorts/core/data/models/page_result.dart';
void main() {
group('PageResult.parse', () {
test('should_parse_page_map_when_total_and_list_present', () {
final page = PageResult.parse({
'total': '3',
'list': [
{'id': '1', 'title': 'A'},
{'id': '2', 'title': 'B'},
],
}, _item);
expect(page.total, 3);
expect(page.list.map((e) => e['id']), ['1', '2']);
});
test('should_parse_legacy_list_when_data_is_array', () {
final page = PageResult.parse([
{'id': '9', 'title': '收藏剧'},
{'id': '8', 'title': '另一部'},
], _item);
expect(page.total, 2);
expect(page.list, hasLength(2));
expect(page.list.first['title'], '收藏剧');
});
test('should_return_empty_page_when_data_is_null_or_empty_list', () {
expect(PageResult.parse(null, _item).total, 0);
expect(PageResult.parse(null, _item).list, isEmpty);
expect(PageResult.parse(const <Object>[], _item).total, 0);
expect(PageResult.parse(const <Object>[], _item).list, isEmpty);
});
test('should_return_empty_page_when_payload_is_invalid', () {
final page = PageResult.parse('broken', _item);
expect(page.total, 0);
expect(page.list, isEmpty);
});
test('should_skip_non_map_entries_in_legacy_list', () {
final page = PageResult.parse([
{'id': '1'},
'noise',
42,
{'id': '2'},
], _item);
expect(page.total, 2);
expect(page.list.map((e) => e['id']), ['1', '2']);
});
});
}
Map<String, dynamic> _item(Map<String, dynamic> json) => json;