test: fixed tests

This commit is contained in:
Folke Lemaitre 2023-09-29 10:19:54 +02:00
parent aa14c5e7b8
commit 4dfb5aceb7
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 18 additions and 3 deletions

View File

@ -1,11 +1,25 @@
local Config = require("lazy.core.config") local Config = require("lazy.core.config")
local Plugin = require("lazy.core.plugin") local Plugin = require("lazy.core.plugin")
local Loader = require("lazy.core.loader")
local assert = require("luassert") local assert = require("luassert")
Config.setup() Config.setup()
---@param plugins LazyPlugin[]|LazyPlugin
local function clean(plugins)
local p = plugins
plugins = type(plugins) == "table" and plugins or { plugins }
for _, plugin in pairs(plugins) do
plugin._.fid = nil
plugin._.fpid = nil
plugin._.fdeps = nil
if plugin._.dep == false then
plugin._.dep = nil
end
end
return p
end
describe("plugin spec url/name", function() describe("plugin spec url/name", function()
local tests = { local tests = {
{ { dir = "~/foo" }, { name = "foo", dir = vim.fn.fnamemodify("~/foo", ":p") } }, { { dir = "~/foo" }, { name = "foo", dir = vim.fn.fnamemodify("~/foo", ":p") } },
@ -28,6 +42,7 @@ describe("plugin spec url/name", function()
end end
local spec = Plugin.Spec.new(test[1]) local spec = Plugin.Spec.new(test[1])
local plugins = vim.tbl_values(spec.plugins) local plugins = vim.tbl_values(spec.plugins)
plugins[1]._ = {}
assert(#spec.notifs == 0) assert(#spec.notifs == 0)
assert.equal(1, #plugins) assert.equal(1, #plugins)
assert.same(test[2], plugins[1]) assert.same(test[2], plugins[1])
@ -61,7 +76,7 @@ describe("plugin spec opt", function()
for _, plugin in pairs(spec.plugins) do for _, plugin in pairs(spec.plugins) do
plugin.dir = nil plugin.dir = nil
end end
assert.same(spec.plugins, { assert.same(clean(spec.plugins), {
bar = { bar = {
"foo/bar", "foo/bar",
_ = {}, _ = {},
@ -105,7 +120,7 @@ describe("plugin spec opt", function()
for _, plugin in pairs(spec.plugins) do for _, plugin in pairs(spec.plugins) do
plugin.dir = nil plugin.dir = nil
end end
assert.same(spec.plugins, { assert.same(clean(spec.plugins), {
bar = { bar = {
"foo/bar", "foo/bar",
_ = {}, _ = {},