From aa5135255c20510dd9a315e751a438c64b14d05c Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 29 Sep 2023 10:36:01 +0200 Subject: [PATCH] test: added tests for disabling fragments --- tests/core/plugin_spec.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/core/plugin_spec.lua b/tests/core/plugin_spec.lua index 61fc439..15eb060 100644 --- a/tests/core/plugin_spec.lua +++ b/tests/core/plugin_spec.lua @@ -350,3 +350,32 @@ describe("plugin opts", function() end end) end) + +describe("plugin spec", function() + it("only includes fragments from enabled plugins", function() + local tests = { + { + spec = { + { "foo/disabled", enabled = false, dependencies = { "foo/bar", opts = { key_disabled = true } } }, + { "foo/disabled", dependencies = { "foo/bar", opts = { key_disabled_two = true } } }, + { "foo/conditional", cond = false, dependencies = { "foo/bar", opts = { key_cond = true } } }, + { "foo/optional", optional = true, dependencies = { "foo/bar", opts = { key_optional = true } } }, + { "foo/active", dependencies = { "foo/bar", opts = { key_active = true } } }, + { + "foo/bar", + opts = { key = true }, + }, + }, + expected_opts = { key = true, key_active = true }, + }, -- for now, one test... + } + for _, test in ipairs(tests) do + local spec = Plugin.Spec.new(test.spec) + assert(#spec.notifs == 0) + assert(vim.tbl_count(spec.plugins) == 2) + assert(spec.plugins.active) + assert(spec.plugins.bar) + assert.same(test.expected_opts, Plugin.values(spec.plugins.bar, "opts")) + end + end) +end)