✨ feat(vscode): handoff 清单类型与校验
Claude-Session: https://claude.ai/code/session_011cEyL6k351U2BzX1Qmygph
This commit is contained in:
1 parent
569f24c11a
commit
65cd404350
2 files changed
+139
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { handoffAttachmentName, parseHandoffManifest } from './handoffManifest'
|
||||
|
||||
const good = {
|
||||
version: 1,
|
||||
issue: 42,
|
||||
from: 'chw',
|
||||
createdAt: '2026-08-26T00:00:00Z',
|
||||
branch: 'feature/x',
|
||||
sessions: { implementSessionId: 'a' },
|
||||
profiles: {},
|
||||
claude: [{ id: 'a', kind: 'implement' }],
|
||||
codex: [],
|
||||
}
|
||||
|
||||
describe('handoffAttachmentName', () => {
|
||||
it('固定命名', () => {
|
||||
expect(handoffAttachmentName(42)).toBe('spx-handoff-issue-42.tgz')
|
||||
})
|
||||
})
|
||||
|
||||
describe('parseHandoffManifest', () => {
|
||||
it('合法清单原样返回', () => {
|
||||
expect(parseHandoffManifest(JSON.stringify(good), 42)).toEqual(good)
|
||||
})
|
||||
it('issue 不匹配 → 抛错', () => {
|
||||
expect(() => parseHandoffManifest(JSON.stringify(good), 43)).toThrow(/42/)
|
||||
})
|
||||
it('version 不是 1 → 抛错', () => {
|
||||
expect(() => parseHandoffManifest(JSON.stringify({ ...good, version: 2 }), 42)).toThrow(/version/)
|
||||
})
|
||||
it('claude 条目 kind 非法 → 抛错', () => {
|
||||
expect(() => parseHandoffManifest(JSON.stringify({ ...good, claude: [{ id: 'a', kind: 'x' }] }), 42)).toThrow(/claude/)
|
||||
})
|
||||
it('不是 JSON → 抛错', () => {
|
||||
expect(() => parseHandoffManifest('nope', 42)).toThrow()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user