read-outline.test.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { test, before, after } from 'node:test'
  2. import assert from 'node:assert/strict'
  3. import { run } from '../../src/commands/read-outline.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('read-outline --总纲 --结局 返回结局段', async () => {
  13. const r = await run([], { 总纲: true, 结局: true }, ctx)
  14. assert.equal(r.ok, true)
  15. assert.ok(r.output.includes('血仇得报'))
  16. })
  17. test('read-outline --总纲 --section=核心冲突 返回该小节', async () => {
  18. const r = await run([], { 总纲: true, section: '核心冲突' }, ctx)
  19. assert.equal(r.ok, true)
  20. assert.ok(r.output.includes('灭门血仇'))
  21. })
  22. test('read-outline --卷=1 返回卷纲全文', async () => {
  23. const r = await run([], { 卷: '1' }, ctx)
  24. assert.equal(r.ok, true)
  25. assert.ok(r.output.includes('卷定位'))
  26. })
  27. test('read-outline --卷=1 --section=卷定位 返回卷内小节', async () => {
  28. const r = await run([], { 卷: '1', section: '卷定位' }, ctx)
  29. assert.equal(r.ok, true)
  30. assert.ok(r.output.includes('开篇立人设'))
  31. })
  32. test('read-outline 不存在的卷 → ok=false', async () => {
  33. const r = await run([], { 卷: '99' }, ctx)
  34. assert.equal(r.ok, false)
  35. })