- 渲染管线迁移至 MetonaEditor 内置解析器,移除 unified/rehype 全家桶(9 个依赖) - 修复相对路径图片修复的目录前缀碰撞与路径解析 bug - ConfirmDialog/useConfirm/LoadingSpinner/useDocStats 移除,改用 MeToast.confirm/loading/promise - 新增状态栏(字数/行数/阅读时间/光标位置)、Zen 模式、数据备份导出导入 - Sqlark: 版本化迁移(addMigration/migrateTo)、subscribe 表变更、备份 exportAll/importTable - 数据库损坏自愈:异常退出残留残缺 SSTable 导致打开失败时自动重建 - 大纲导航改用 scrollToLine 官方 API - 修复 rollup 平台包互删(postinstall 自动补齐)+ 集成测试(fake-indexeddb)
35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
import 'fake-indexeddb/auto'
|
|
import { describe, it, expect } from 'vitest'
|
|
import { recentFilesRepository } from '../recentFilesRepository'
|
|
|
|
describe('recentFilesRepository (真实 AriaEngine + IndexedDB)', () => {
|
|
it('should add and read recent files', async () => {
|
|
await recentFilesRepository.add('/test/a.md')
|
|
const files = await recentFilesRepository.getAll(10)
|
|
expect(files).toContain('/test/a.md')
|
|
})
|
|
|
|
it('should update lastOpened on re-add', async () => {
|
|
await recentFilesRepository.add('/test/b.md')
|
|
await new Promise(r => setTimeout(r, 5))
|
|
await recentFilesRepository.add('/test/b.md')
|
|
const files = await recentFilesRepository.getAll(10)
|
|
expect(files[0]).toBe('/test/b.md')
|
|
})
|
|
|
|
it('should enforce 50 item limit', async () => {
|
|
for (let i = 0; i < 55; i++) {
|
|
await recentFilesRepository.add(`/test/f${String(i).padStart(2, '0')}.md`)
|
|
}
|
|
const files = await recentFilesRepository.getAll(60)
|
|
expect(files.length).toBeLessThanOrEqual(50)
|
|
})
|
|
|
|
it('should remove a file', async () => {
|
|
await recentFilesRepository.add('/test/remove-me.md')
|
|
await recentFilesRepository.remove('/test/remove-me.md')
|
|
const files = await recentFilesRepository.getAll(60)
|
|
expect(files).not.toContain('/test/remove-me.md')
|
|
})
|
|
})
|