39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { translateCommand, getAllCommands } from '../src/utils/command-translator.js'
|
|
|
|
describe('command-translator', () => {
|
|
it('translates simple commands', () => {
|
|
const r = translateCommand('list files')
|
|
expect(r.success).toBe(true)
|
|
expect(r.command).toBe('ls -la')
|
|
})
|
|
|
|
it('translates git commands', () => {
|
|
const r = translateCommand('git status')
|
|
expect(r.success).toBe(true)
|
|
expect(r.command).toBe('git status')
|
|
})
|
|
|
|
it('marks dangerous commands', () => {
|
|
const r = translateCommand('remove directory')
|
|
expect(r.success).toBe(true)
|
|
expect(r.dangerous).toBe(true)
|
|
})
|
|
|
|
it('handles unknown input gracefully', () => {
|
|
const r = translateCommand('xyz')
|
|
expect(r.success).toBe(false)
|
|
})
|
|
|
|
it('handles empty input', () => {
|
|
const r = translateCommand('')
|
|
expect(r.success).toBe(false)
|
|
expect(r.error).toBe('Empty input')
|
|
})
|
|
|
|
it('has a command catalog', () => {
|
|
const cmds = getAllCommands()
|
|
expect(cmds.length).toBeGreaterThan(20)
|
|
})
|
|
})
|