refactor: 收口排行配置模型
This commit is contained in:
@@ -7,14 +7,18 @@ import {
|
||||
buildPublicCategoryGroups,
|
||||
buildPublicGalleryCardKey,
|
||||
dedupePlatformPublicGalleryEntries,
|
||||
DEFAULT_PLATFORM_RANKING_TAB,
|
||||
filterPlatformWorkSearchResults,
|
||||
filterTodayPublishedEntries,
|
||||
getPlatformCategoryKindFilter,
|
||||
getPlatformCategoryPrimaryMetric,
|
||||
getPlatformPublicEntries,
|
||||
getPlatformRankingMetric,
|
||||
getPlatformRankingMetricValue,
|
||||
getPlatformRankingTabConfig,
|
||||
matchesPlatformCategoryKindFilter,
|
||||
parsePlatformEntryTimestamp,
|
||||
PLATFORM_RANKING_TABS,
|
||||
selectAdjacentPlatformRecommendEntry,
|
||||
selectPlatformRecommendFeedWindow,
|
||||
sortPlatformCategoryEntries,
|
||||
@@ -335,11 +339,32 @@ test('public gallery ViewModel ranks entries by selected metric', () => {
|
||||
});
|
||||
const entries = [recentWinner, remixWinner, likeWinner, playWinner];
|
||||
|
||||
expect(DEFAULT_PLATFORM_RANKING_TAB).toBe('hot');
|
||||
expect(PLATFORM_RANKING_TABS.map((tab) => tab.label)).toEqual([
|
||||
'热门榜',
|
||||
'改造榜',
|
||||
'新品榜',
|
||||
'点赞榜',
|
||||
]);
|
||||
expect(getPlatformRankingTabConfig('new')).toEqual({
|
||||
id: 'new',
|
||||
label: '新品榜',
|
||||
metricLabel: '近7日',
|
||||
emptyText: '近 7 日暂时还没有新品。',
|
||||
});
|
||||
expect(buildPlatformRankingEntries(entries, 'hot')[0]).toBe(playWinner);
|
||||
expect(buildPlatformRankingEntries(entries, 'remix')[0]).toBe(remixWinner);
|
||||
expect(buildPlatformRankingEntries(entries, 'new')[0]).toBe(recentWinner);
|
||||
expect(buildPlatformRankingEntries(entries, 'like')[0]).toBe(likeWinner);
|
||||
expect(getPlatformRankingMetricValue(likeWinner, 'like')).toBe(40);
|
||||
expect(getPlatformRankingMetric(recentWinner, 'new')).toEqual({
|
||||
label: '近7日',
|
||||
value: 30,
|
||||
});
|
||||
expect(getPlatformRankingMetric(playWinner, 'hot')).toEqual({
|
||||
label: '游玩',
|
||||
value: 100,
|
||||
});
|
||||
});
|
||||
|
||||
test('public gallery ViewModel sorts category entries and exposes primary metric', () => {
|
||||
|
||||
Reference in New Issue
Block a user