TimelineReader.test.js 1.1 KB

123456789101112131415161718192021222324252627
  1. import { test } from 'node:test'
  2. import assert from 'node:assert/strict'
  3. import path from 'node:path'
  4. import { fileURLToPath } from 'node:url'
  5. import { TimelineReader } from '../../../src/storage/adapters/TimelineReader.js'
  6. const __dirname = path.dirname(fileURLToPath(import.meta.url))
  7. const fixtureRoot = path.join(__dirname, '../../fixtures/sample-book')
  8. test('TimelineReader.readVolumeRange 读卷时间线(Markdown 表格行)', async () => {
  9. const r = await new TimelineReader(fixtureRoot).readVolumeRange(1, 1)
  10. assert.equal(r.ok, true)
  11. assert.ok(r.timeline.length >= 1)
  12. assert.ok(r.timeline[0].在场.includes('林晚'))
  13. })
  14. test('TimelineReader.readByParticipant 按在场角色过滤', async () => {
  15. const rows = await new TimelineReader(fixtureRoot).readByParticipant(1, '林晚')
  16. assert.ok(rows.length >= 1)
  17. assert.ok(rows.every((e) => e.在场.includes('林晚')))
  18. })
  19. test('TimelineReader 不存在的卷 → 空时间线(不崩)', async () => {
  20. const r = await new TimelineReader(fixtureRoot).readVolumeRange(99, 99)
  21. assert.equal(r.ok, true)
  22. assert.deepEqual(r.timeline, [])
  23. })