mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(replies): order approved queue replies
This commit is contained in:
@@ -2,7 +2,14 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { copyToClipboard } from '../clipboard-utils';
|
||||
import { hashStringToColor, getTextColorForBackground, removeMarkdown } from '../post-utils';
|
||||
import { preloadReplyModal, preloadThemeAssets, resolveAssetUrl } from '../preload-utils';
|
||||
import { computeOmittedCount, filterRepliesForDisplay, getPreviewDisplayReplies, getTotalReplyCount, hasEnoughPreviewReplies } from '../replies-preview-utils';
|
||||
import {
|
||||
computeOmittedCount,
|
||||
filterRepliesForDisplay,
|
||||
getPreviewDisplayReplies,
|
||||
getTotalReplyCount,
|
||||
hasEnoughPreviewReplies,
|
||||
sortRepliesForDisplay,
|
||||
} from '../replies-preview-utils';
|
||||
import { getQuotedCidsFromContent, mergeQuotedCids } from '../reply-quote-utils';
|
||||
import { formatUserIDForDisplay, truncateWithEllipsisInMiddle } from '../string-utils';
|
||||
import { getFormattedDate, getFormattedTimeAgo, isChristmas } from '../time-utils';
|
||||
@@ -184,6 +191,33 @@ describe('misc utils', () => {
|
||||
{ cid: 'pending', pendingApproval: true },
|
||||
]);
|
||||
|
||||
expect(
|
||||
sortRepliesForDisplay([
|
||||
{ cid: 'reply-8', number: 8 },
|
||||
{ cid: 'reply-12', number: 12 },
|
||||
{ cid: 'reply-11', number: 11 },
|
||||
]),
|
||||
).toEqual([
|
||||
{ cid: 'reply-8', number: 8 },
|
||||
{ cid: 'reply-11', number: 11 },
|
||||
{ cid: 'reply-12', number: 12 },
|
||||
]);
|
||||
|
||||
expect(
|
||||
getPreviewDisplayReplies(
|
||||
[
|
||||
{ cid: 'reply-8', number: 8, timestamp: 8 },
|
||||
{ cid: 'reply-12', number: 12, timestamp: 12 },
|
||||
{ cid: 'reply-11', number: 11, timestamp: 99 },
|
||||
],
|
||||
3,
|
||||
),
|
||||
).toEqual([
|
||||
{ cid: 'reply-8', number: 8, timestamp: 8 },
|
||||
{ cid: 'reply-11', number: 11, timestamp: 99 },
|
||||
{ cid: 'reply-12', number: 12, timestamp: 12 },
|
||||
]);
|
||||
|
||||
expect(computeOmittedCount({ totalReplyCount: 2, visibleCount: 5 })).toBe(0);
|
||||
expect(computeOmittedCount({ totalReplyCount: 9, visibleCount: 5 })).toBe(4);
|
||||
expect(hasEnoughPreviewReplies({ replyCount: 2, loadedCount: 2, visibleCount: 5 })).toBe(true);
|
||||
|
||||
Reference in New Issue
Block a user