read-timeline.test.js 747 B

12345678910111213141516171819202122232425
  1. import { test, before, after } from 'node:test'
  2. import assert from 'node:assert/strict'
  3. import { run } from '../../src/commands/read-timeline.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-timeline --current-and-prev 返回时间线数组', async () => {
  13. const r = await run([], { 'current-and-prev': true }, ctx)
  14. assert.equal(r.ok, true)
  15. const timeline = JSON.parse(r.output)
  16. assert.ok(Array.isArray(timeline))
  17. assert.ok(timeline.length >= 1)
  18. })
  19. test('read-timeline 无任何选项 → ok=false(提示需指定)', async () => {
  20. const r = await run([], {}, ctx)
  21. assert.equal(r.ok, false)
  22. })