feat: publish CodexPi contest snapshot
Some checks are pending
Qualité / tests (push) Waiting to run
Some checks are pending
Qualité / tests (push) Waiting to run
This commit is contained in:
26
frontend/tests/slashCommands.test.ts
Normal file
26
frontend/tests/slashCommands.test.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
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 ')
|
||||
})
|
||||
Reference in New Issue
Block a user