repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

neovim/tests/std/cheatsheet_spec.lua

Raw
-- Test the actual module at lua/std/cheatsheet.lua
local cheatsheet = require 'std.cheatsheet'

local get_category_icon = cheatsheet.get_category_icon
local parse_description = cheatsheet.parse_description

describe('std.cheatsheet helpers', function()
	describe('get_category_icon', function()
		it('should return LSP for lsp', function()
			assert.equals('LSP', get_category_icon('lsp'))
		end)

		it('should return FZF for fuzzy', function()
			assert.equals('FZF', get_category_icon('fuzzy'))
		end)

		it('should return FILE for files', function()
			assert.equals('FILE', get_category_icon('files'))
		end)

		it('should return uppercase fallback for unknown category', function()
			assert.equals('UNKNOWN', get_category_icon('unknown'))
		end)
	end)

	describe('parse_description', function()
		it('should parse lsp: hover', function()
			local cat, desc = parse_description('lsp: hover')
			assert.equals('lsp', cat)
			assert.equals('hover', desc)
		end)

		it('should parse fuzzy: find files', function()
			local cat, desc = parse_description('fuzzy: find files')
			assert.equals('fuzzy', cat)
			assert.equals('find files', desc)
		end)

		it('should parse files: open', function()
			local cat, desc = parse_description('files: open')
			assert.equals('files', cat)
			assert.equals('open', desc)
		end)

		it('should parse terminal: new terminal', function()
			local cat, desc = parse_description('terminal: new terminal')
			assert.equals('terminal', cat)
			assert.equals('new terminal', desc)
		end)

		it('should parse editing: something', function()
			local cat, desc = parse_description('editing: something')
			assert.equals('editing', cat)
			assert.equals('something', desc)
		end)

		it('should parse search: grep', function()
			local cat, desc = parse_description('search: grep')
			assert.equals('search', cat)
			assert.equals('grep', desc)
		end)

		it('should parse session: save', function()
			local cat, desc = parse_description('session: save')
			assert.equals('session', cat)
			assert.equals('save', desc)
		end)

		it('should parse diff: show', function()
			local cat, desc = parse_description('diff: show')
			assert.equals('diff', cat)
			assert.equals('show', desc)
		end)

		it('should parse operator: move', function()
			local cat, desc = parse_description('operator: move')
			assert.equals('operator', cat)
			assert.equals('move', desc)
		end)

		it('should parse fun: easter egg', function()
			local cat, desc = parse_description('fun: easter egg')
			assert.equals('fun', cat)
			assert.equals('easter egg', desc)
		end)

		it('should return general for text without prefix', function()
			local cat, desc = parse_description('no prefix text')
			assert.equals('general', cat)
			assert.equals('no prefix text', desc)
		end)

		it('should return *no description* for empty string', function()
			local cat, desc = parse_description('')
			assert.equals('general', cat)
			assert.equals('*no description*', desc)
		end)

		it('should return *no description* for nil', function()
			local cat, desc = parse_description(nil)
			assert.equals('general', cat)
			assert.equals('*no description*', desc)
		end)
	end)
end)