skillhub/cli/test/unit/platform/updater.test.ts
dongmucat e249db35a3 test(cli): add comprehensive integration tests and fix update command bugs
- Add integration tests for doctor, install, list, publish, remove, whoami commands
- Expand fake-registry with resolve/delete state capture for real assertions
- Fix update command: use correct package name @astron-team/skillhub from constants
- Refactor runUpdateCommand to accept string[] instead of fragile string splitting
- Add dependency injection to updateCommand for testable unit tests without global mocks
- Replace package.json import with codegen (scripts/generate-pkg-info.ts) to avoid
  leaking devDependencies into the build artifact
- Fix startNetworkFailureServer TOCTOU race by keeping listener alive
- Add TODO markers for known help command bugs (--json not forwarded, unknown topic crash)
- Extend update integration test timeout for real npm registry checks
2026-05-07 14:46:40 +08:00

26 lines
928 B
TypeScript

import { describe, expect, test } from 'bun:test'
import { runUpdateCommand } from '../../../src/platform/updater'
describe('runUpdateCommand', () => {
test('succeeds with node --version', async () => {
const result = await runUpdateCommand(['node', '--version'])
expect(result.success).toBe(true)
expect(result.output).toMatch(/v\d+\.\d+/)
})
test('fails on invalid node flag', async () => {
const result = await runUpdateCommand(['node', '--invalid-flag-xyz-12345'])
expect(result.success).toBe(false)
})
test('returns failure for empty command', async () => {
const result = await runUpdateCommand([])
expect(result.success).toBe(false)
expect(result.output).toBe('empty update command')
})
test('handles spawn error for missing binary', async () => {
const result = await runUpdateCommand(['nonexistent-binary-xyz-12345'])
expect(result.success).toBe(false)
})
})