- Guard formatDescriptionWithSource() so missing command descriptions become '' - Harden truncate helpers to accept undefined text/path safely - Add regression tests covering undefined input cases
31 lines
768 B
TypeScript
31 lines
768 B
TypeScript
import { formatDescriptionWithSource } from './commands.js'
|
|
|
|
describe('formatDescriptionWithSource', () => {
|
|
test('returns empty text for prompt commands missing a description', () => {
|
|
const command = {
|
|
name: 'example',
|
|
type: 'prompt',
|
|
source: 'builtin',
|
|
description: undefined,
|
|
} as any
|
|
|
|
expect(formatDescriptionWithSource(command)).toBe('')
|
|
})
|
|
|
|
test('formats plugin commands with missing description safely', () => {
|
|
const command = {
|
|
name: 'example',
|
|
type: 'prompt',
|
|
source: 'plugin',
|
|
description: undefined,
|
|
pluginInfo: {
|
|
pluginManifest: {
|
|
name: 'MyPlugin',
|
|
},
|
|
},
|
|
} as any
|
|
|
|
expect(formatDescriptionWithSource(command)).toBe('(MyPlugin) ')
|
|
})
|
|
})
|