report-book-stats.test.js 713 B

12345678910111213141516171819202122
  1. import { test, before, after } from 'node:test'
  2. import assert from 'node:assert/strict'
  3. import { run } from '../../src/commands/report-book-stats.js'
  4. import { fixtureCtx } from './_helper.js'
  5. let ctx, cleanup
  6. before(async () => {
  7. ;({ ctx, cleanup } = await fixtureCtx())
  8. })
  9. after(async () => {
  10. await cleanup()
  11. })
  12. test('report-book-stats 返回总章数/总字数/条目数/角色数', async () => {
  13. const r = await run([], {}, ctx)
  14. assert.equal(r.ok, true)
  15. const s = JSON.parse(r.output)
  16. assert.equal(s.总章数, 2)
  17. assert.equal(s.总字数, 5400) // 2800 + 2600
  18. assert.equal(s.条目数, 3) // 伏笔-001 + 悬念-001 + 感情线-001
  19. assert.equal(s.角色数, 2) // 林晚 + 神秘老者
  20. })