Files
codexpi/frontend/tests/slashCommands.test.ts

27 lines
1.1 KiB
TypeScript
Raw Permalink Normal View History

2026-11-14 20:23:59 +01:00
import assert from 'node:assert/strict'
import test from 'node:test'
import { SLASH_COMMANDS, filterSlashCommands, slashCommandValue } from '../src/slashCommands.ts'
test('a lone slash exposes the available command catalog', () => {
assert.ok(SLASH_COMMANDS.length >= 8)
assert.deepEqual(filterSlashCommands('/'), SLASH_COMMANDS)
})
test('a command prefix filters names case-insensitively', () => {
assert.deepEqual(filterSlashCommands('/plu').map(item => item.name), ['/plugins'])
assert.deepEqual(filterSlashCommands('/PLU').map(item => item.name), ['/plugins'])
})
test('suggestions only appear for a single command token at the start', () => {
assert.deepEqual(filterSlashCommands('bonjour /'), [])
assert.deepEqual(filterSlashCommands('/plugins maintenant'), [])
assert.deepEqual(filterSlashCommands('/plugins\ntexte'), [])
})
test('selecting a command leaves a space ready for optional arguments', () => {
const plugins = SLASH_COMMANDS.find(item => item.name === '/plugins')
assert.ok(plugins)
assert.equal(slashCommandValue(plugins), '/plugins ')
})