report-thread-activity.test.js 873 B

123456789101112131415161718192021222324252627
  1. import { test, before, after } from 'node:test'
  2. import assert from 'node:assert/strict'
  3. import { run } from '../../src/commands/report-thread-activity.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-thread-activity --卷=1 返回本卷开/推进/收尾', async () => {
  13. const r = await run([], { 卷: '1' }, ctx)
  14. assert.equal(r.ok, true)
  15. const rep = JSON.parse(r.output)
  16. assert.equal(rep.卷, 1)
  17. const openedIds = rep.本卷开.map((t) => t.id)
  18. assert.ok(openedIds.includes('伏笔-001')) // 开启章 1 在第1卷范围
  19. assert.deepEqual(rep.本卷收尾, []) // fixture 无已收尾
  20. })
  21. test('report-thread-activity 缺 --卷 → ok=false', async () => {
  22. const r = await run([], {}, ctx)
  23. assert.equal(r.ok, false)
  24. })