feat: show three recent updates on the homepage
Publish GitHub Pages output / publish (push) Successful in 42s
Publish GitHub Pages output / publish (push) Successful in 42s
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { parseUpdateHistoryDocument } from '../update-history-document.ts';
|
||||
import { parseUpdateHistoryDocument, recentUpdateEntries } from '../update-history-document.ts';
|
||||
|
||||
test('업데이트 Markdown의 최근 업데이트 시각을 본문과 분리한다', () => {
|
||||
const document = parseUpdateHistoryDocument('---\nupdatedAt: 2026-08-31T14:15:17+09:00\n---\n\n## 업데이트');
|
||||
@@ -13,3 +13,20 @@ test('메타데이터가 없는 Markdown도 그대로 표시한다', () => {
|
||||
const markdown = '## 업데이트';
|
||||
assert.deepEqual(parseUpdateHistoryDocument(markdown), { updatedAt: null, body: markdown });
|
||||
});
|
||||
|
||||
test('최근 업데이트 3개를 날짜 경계를 넘어 문서 순서대로 가져온다', () => {
|
||||
const body = '## 2026년 9월 2일\r\n\r\n### 첫 업데이트\r\n설명\r\n### 다음 업데이트\r\n\r\n---\r\n## 2026년 9월 1일\r\n### 이전 업데이트\r\n### 네 번째 업데이트';
|
||||
assert.deepEqual(recentUpdateEntries(body), [
|
||||
{ date: '2026년 9월 2일', title: '첫 업데이트' },
|
||||
{ date: '2026년 9월 2일', title: '다음 업데이트' },
|
||||
{ date: '2026년 9월 1일', title: '이전 업데이트' }
|
||||
]);
|
||||
});
|
||||
|
||||
test('업데이트가 부족하거나 없으면 있는 항목만 표시한다', () => {
|
||||
assert.deepEqual(recentUpdateEntries('### 날짜 없는 제목'), []);
|
||||
assert.deepEqual(recentUpdateEntries(''), []);
|
||||
assert.deepEqual(recentUpdateEntries('## 2026년 9월 2일\n### 한 항목'), [
|
||||
{ date: '2026년 9월 2일', title: '한 항목' }
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user