diff --git a/.gitignore b/.gitignore index faee0c43..3ecdfae2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /luals-out/ /luals/ +/plenary.nvim/ # backup vim files *~ diff --git a/.luarc.json b/.luarc.json index bb0a84b9..1cef7a9b 100644 --- a/.luarc.json +++ b/.luarc.json @@ -4,7 +4,8 @@ "workspace": { "library": [ "$VIMRUNTIME/lua/vim", - "${3rd}/luv/library" + "${3rd}/luv/library", + "plenary.nvim" ] }, "diagnostics": { diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100755 index 00000000..9c2b18db --- /dev/null +++ b/scripts/test.sh @@ -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!" + diff --git a/tests/minimal_init.lua b/tests/minimal_init.lua new file mode 100644 index 00000000..0678145c --- /dev/null +++ b/tests/minimal_init.lua @@ -0,0 +1 @@ +-- this file is necessary for the minimal_init option which directs the spawned nvim test instances be run with --noplugin diff --git a/tests/unit/utils_spec.lua b/tests/unit/utils_spec.lua new file mode 100644 index 00000000..51fb50d4 --- /dev/null +++ b/tests/unit/utils_spec.lua @@ -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)