list-volumes.test.js 644 B

12345678910111213141516171819202122
  1. import { test, before, after } from 'node:test'
  2. import assert from 'node:assert/strict'
  3. import { run } from '../../src/commands/list-volumes.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('list-volumes 返回卷号与章数范围', async () => {
  13. const r = await run([], {}, ctx)
  14. assert.equal(r.ok, true)
  15. const vols = JSON.parse(r.output)
  16. const v1 = vols.find((v) => v.卷号 === 1)
  17. assert.ok(v1, `应含第1卷,实际:${r.output}`)
  18. assert.equal(v1.起始章, 1)
  19. assert.equal(v1.结束章, 2)
  20. })