chore: plenary tests POC

This commit is contained in:
Alexander Courtis
2025-02-01 18:05:23 +11:00
parent 9ac1e05fc8
commit 2dcf249d49
4 changed files with 38 additions and 4 deletions

View File

@@ -1 +1,8 @@
-- this file is necessary for the minimal_init option which directs the spawned nvim test instances be run with --noplugin
-- ensure that this nvim-tree is not overridden by installed versions in .local/share/nvim/site etc.
vim.o.runtimepath = vim.env.REPO_DIR .. "," .. vim.o.runtimepath
-- plenary will append ,.,$HOME/src/nvim-tree/master/plenary.nvim in the spawned test instances, however we want this here to prevent overrides
vim.o.runtimepath = vim.env.PLENARY_DIR .. "," .. vim.o.runtimepath

View File

@@ -1,5 +1,6 @@
---@type Luassert
local assert = require("luassert")
local stub = require("luassert.stub")
local utils = require("nvim-tree.utils")
@@ -8,10 +9,29 @@ describe("utils.path_add_trailing", function()
end)
it("trailing added", function()
assert.equals(utils.path_add_trailing("foo"), "foo/")
assert.equals("foo/", utils.path_add_trailing("foo"))
end)
it("trailing already present", function()
assert.equals(utils.path_add_trailing("foo/"), "foo/")
assert.equals("foo/", utils.path_add_trailing("foo/"))
end)
end)
describe("utils.canonical_path", function()
before_each(function()
stub(vim.fn, "has")
end)
after_each(function()
end)
it("is windows", function()
vim.fn.has.on_call_with("win32unix").returns(1)
assert.equals("C:\\foo\\bar", utils.canonical_path("c:\\foo\\bar"), "should be uppercase drive")
end)
it("not windows", function()
assert.equals("c:\\foo\\bar", utils.canonical_path("c:\\foo\\bar"))
end)
end)