book-status.test.js 863 B

1234567891011121314151617181920212223242526
  1. import { test, before, after } from 'node:test'
  2. import assert from 'node:assert/strict'
  3. import { assembleBookStatus } from '../../src/prep/book-status.js'
  4. import { fixtureCtx } from '../commands/_helper.js'
  5. let ctx, cleanup
  6. before(async () => {
  7. ;({ ctx, cleanup } = await fixtureCtx())
  8. })
  9. after(async () => {
  10. await cleanup()
  11. })
  12. test('assembleBookStatus 产结构化近况 + Markdown', async () => {
  13. const r = await assembleBookStatus(ctx)
  14. assert.equal(r.ok, true)
  15. // fixture:2 章、卷 1、卷规模 40
  16. assert.equal(r.data.当前卷, 1)
  17. assert.equal(r.data.卷内进度.写到, 2)
  18. assert.equal(r.data.卷内进度.卷规模, 40)
  19. assert.equal(r.data.总章数, 2)
  20. assert.equal(r.data.连续弱钩, 0)
  21. assert.ok(Array.isArray(r.data.悬了太久))
  22. assert.match(r.markdown, /第\s*1\s*卷/)
  23. assert.match(r.markdown, /连续弱钩/)
  24. })