feat(v2.7): 接入协作治理前端体验
This commit is contained in:
20
apps/web/lib/notification.test.ts
Normal file
20
apps/web/lib/notification.test.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { countUnreadNotifications, sortNotificationsNewestFirst } from './notification';
|
||||
|
||||
test('countUnreadNotifications counts only rows without readAt', () => {
|
||||
assert.equal(countUnreadNotifications([
|
||||
{ id: 'n-1', readAt: null } as any,
|
||||
{ id: 'n-2', readAt: '2026-07-08T08:00:00.000Z' } as any,
|
||||
{ id: 'n-3' } as any,
|
||||
]), 2);
|
||||
});
|
||||
|
||||
test('sortNotificationsNewestFirst keeps newest createdAt first', () => {
|
||||
const sorted = sortNotificationsNewestFirst([
|
||||
{ id: 'old', createdAt: '2026-07-07T08:00:00.000Z' } as any,
|
||||
{ id: 'new', createdAt: '2026-07-08T08:00:00.000Z' } as any,
|
||||
]);
|
||||
|
||||
assert.deepEqual(sorted.map((item) => item.id), ['new', 'old']);
|
||||
});
|
||||
Reference in New Issue
Block a user