chore: plenary tests POC

This commit is contained in:
Alexander Courtis 2025-02-01 17:22:41 +11:00
parent d05881f65f
commit 9ac1e05fc8
5 changed files with 37 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
/luals-out/
/luals/
/plenary.nvim/
# backup vim files
*~

View File

@ -4,7 +4,8 @@
"workspace": {
"library": [
"$VIMRUNTIME/lua/vim",
"${3rd}/luv/library"
"${3rd}/luv/library",
"plenary.nvim"
]
},
"diagnostics": {

16
scripts/test.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
set -e
# TODO add ability for user to specify a test file or directory
REPO_DIR="$(git rev-parse --show-toplevel)"
PLENARY_DIR="${REPO_DIR}/plenary.nvim"
nvim --headless \
--clean \
--noplugin \
-c "set runtimepath+=${PLENARY_DIR}" \
-c "lua require('plenary.test_harness').test_directory('tests/', { minimal_init = './tests/minimal_init.lua' })" \
-c "qa!"

1
tests/minimal_init.lua Normal file
View File

@ -0,0 +1 @@
-- this file is necessary for the minimal_init option which directs the spawned nvim test instances be run with --noplugin

17
tests/unit/utils_spec.lua Normal file
View File

@ -0,0 +1,17 @@
---@type Luassert
local assert = require("luassert")
local utils = require("nvim-tree.utils")
describe("utils.path_add_trailing", function()
before_each(function()
end)
it("trailing added", function()
assert.equals(utils.path_add_trailing("foo"), "foo/")
end)
it("trailing already present", function()
assert.equals(utils.path_add_trailing("foo/"), "foo/")
end)
end)