test: add store, parse, and diff specs

Problem: need test coverage for core data operations, inline
metadata parsing, and buffer diff algorithm.

Solution: add busted specs for store CRUD, round-trip
preservation, parse body/command_add with configurable date
syntax, and diff create/delete/update/copy/move operations.
This commit is contained in:
Barrett Ruth 2026-02-24 15:10:09 -05:00 committed by Barrett Ruth
parent dfe09ef721
commit 8bd6bf8a6a
4 changed files with 483 additions and 0 deletions

38
spec/helpers.lua Normal file
View file

@ -0,0 +1,38 @@
local plugin_dir = vim.fn.getcwd()
vim.opt.runtimepath:prepend(plugin_dir)
vim.opt.packpath = {}
vim.cmd('filetype on')
local M = {}
---@param lines? string[]
---@return integer
function M.create_buffer(lines)
local bufnr = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, lines or {})
return bufnr
end
---@param bufnr integer
function M.delete_buffer(bufnr)
if bufnr and vim.api.nvim_buf_is_valid(bufnr) then
vim.api.nvim_buf_delete(bufnr, { force = true })
end
end
---@param bufnr integer
---@param ns integer
---@return table[]
function M.get_extmarks(bufnr, ns)
return vim.api.nvim_buf_get_extmarks(bufnr, ns, 0, -1, { details = true })
end
---@return string
function M.tmpdir()
local dir = vim.fn.tempname()
vim.fn.mkdir(dir, 'p')
return dir
end
return M