read-worldview.test.js 863 B

1234567891011121314151617181920212223242526272829
  1. import { test, before, after } from 'node:test'
  2. import assert from 'node:assert/strict'
  3. import { run } from '../../src/commands/read-worldview.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-worldview --section=修炼体系 返回该小节', async () => {
  13. const r = await run([], { section: '修炼体系' }, ctx)
  14. assert.equal(r.ok, true)
  15. assert.ok(r.output.includes('练气'))
  16. assert.ok(!r.output.includes('## 势力'))
  17. })
  18. test('read-worldview 缺 --section → ok=false', async () => {
  19. const r = await run([], {}, ctx)
  20. assert.equal(r.ok, false)
  21. })
  22. test('read-worldview 不存在的小节 → ok=false', async () => {
  23. const r = await run([], { section: '不存在的节' }, ctx)
  24. assert.equal(r.ok, false)
  25. })