Skip to content

一分钟搭建影视站,支持Docker等部署方式

test: 同步用例至 list:null 兼容与原生封面优先的新行为

bestZweia5cd6dee0928
diff --git a/src/lib/cms-parser.test.ts b/src/lib/cms-parser.test.ts
index 7eaf190..08d9b29 100644
--- a/src/lib/cms-parser.test.ts
+++ b/src/lib/cms-parser.test.ts
@@ -37,10 +37,12 @@ describe('parseSearchList', () => {
expect(items[0].name).toBe('');
});
- it('拒绝无效响应', () => {
+ it('拒绝无效响应;list 缺失或 null 视为空结果', () => {
expect(() => parseSearchList(null, source)).toThrow();
- expect(() => parseSearchList({}, source)).toThrow();
expect(() => parseSearchList({ list: 'nope' }, source)).toThrow();
+ // 部分源站无结果时返回 list: null(或缺失),按空结果兼容
+ expect(parseSearchList({ list: null }, source)).toEqual([]);
+ expect(parseSearchList({}, source)).toEqual([]);
});
});
diff --git a/src/lib/douban-weekly.test.ts b/src/lib/douban-weekly.test.ts
index 13fdee5..cad5201 100644
--- a/src/lib/douban-weekly.test.ts
+++ b/src/lib/douban-weekly.test.ts
@@ -11,7 +11,7 @@ describe('isHotListId', () => {
});
describe('doubanWeeklyToItem', () => {
- it('评分、封面代理、isTv 正确映射', () => {
+ it('评分、封面(原生地址优先)、isTv 正确映射', () => {
const item = doubanWeeklyToItem(
{
id: 36808876,
@@ -22,19 +22,25 @@ describe('doubanWeeklyToItem', () => {
},
false
);
+ // 原生 doubanio 地址命中图片代理白名单并带 Referer 伪装,优先于 cover_proxy 镜像
expect(item).toEqual({
id: '36808876',
title: '奥德赛',
- cover: 'https://doubanio.viki.moe/view/photo/p1.jpg',
+ cover: 'https://img9.doubanio.com/view/photo/p1.jpg',
rating: '8.6',
isTv: false,
});
});
- it('cover_proxy 缺失时回退 cover,0 分不输出 rating', () => {
- const item = doubanWeeklyToItem({ id: 1, title: 'x', cover: 'c', rating: 0 }, true);
- expect(item).toMatchObject({ cover: 'c', isTv: true });
- expect(item?.rating).toBeUndefined();
+ it('原生 cover 缺失时回退 cover_proxy,0 分不输出 rating', () => {
+ const item = doubanWeeklyToItem(
+ { id: 2, title: 'y', cover_proxy: 'https://doubanio.viki.moe/view/photo/p2.jpg' },
+ true
+ );
+ expect(item).toMatchObject({ cover: 'https://doubanio.viki.moe/view/photo/p2.jpg', isTv: true });
+ const zero = doubanWeeklyToItem({ id: 1, title: 'x', cover: 'c', rating: 0 }, true);
+ expect(zero).toMatchObject({ cover: 'c', isTv: true });
+ expect(zero?.rating).toBeUndefined();
});
it('缺 id、标题或封面的脏数据丢弃', () => {