repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by bugabinga
neovim/tests/bugabinga/cmdline/format_spec.lua
Rawlocal format = require 'bugabinga.cmdline.format'
describe('format.detect', function()
it('detects : as cmdline', function()
local result = format.detect(':', 'hello', '')
assert.equals('cmdline', result.type)
assert.equals('', result.icon)
end)
it('detects / as search_down', function()
local result = format.detect('/', 'hello', '')
assert.equals('search_down', result.type)
assert.equals('', result.icon)
end)
it('detects ? as search_up', function()
local result = format.detect('?', 'hello', '')
assert.equals('search_up', result.type)
assert.equals('', result.icon)
end)
it('detects :lua as lua', function()
local result = format.detect(':', 'lua print("hi")', '')
assert.equals('lua', result.type)
assert.equals('', result.icon)
end)
it('detects := as lua', function()
local result = format.detect(':', '= { foo = 1 }', '')
assert.equals('lua', result.type)
assert.equals('', result.icon)
end)
it('detects input when prompt is non-empty', function()
local result = format.detect(':', 'some input', 'Enter name: ')
assert.equals('input', result.type)
assert.equals('', result.icon)
end)
it('returns cmdline for unknown firstc', function()
local result = format.detect('-', 'some text', '')
assert.equals('cmdline', result.type)
end)
it('returns cmdline for empty firstc', function()
local result = format.detect('', 'some text', '')
assert.equals('cmdline', result.type)
end)
it('handles nil content gracefully', function()
local result = format.detect(':', nil, '')
assert.equals('cmdline', result.type)
end)
end)