From c8e574b9e66dd6dfffc382b90e9c4132f0a00953 Mon Sep 17 00:00:00 2001 From: tris203 Date: Wed, 3 Jan 2024 21:27:48 +0000 Subject: [PATCH] remove mini.test --- tests/hawtkeys/ui_spec.lua | 106 +++++++++++++++++-------------------- tests/minimal_init.lua | 11 ---- 2 files changed, 50 insertions(+), 67 deletions(-) diff --git a/tests/hawtkeys/ui_spec.lua b/tests/hawtkeys/ui_spec.lua index 8b2b594..0766728 100644 --- a/tests/hawtkeys/ui_spec.lua +++ b/tests/hawtkeys/ui_spec.lua @@ -1,71 +1,62 @@ ---@diagnostic disable-next-line: undefined-field local eq = assert.are.same -local function getTestPath() - if package.config:sub(1, 1) == "\\" then - return "tests\\minimal_init.lua" - else - return "tests/minimal_init.lua" - end -end - -local MiniTest = require("mini.test") - ---TODO: add search functionality tests (willothy) describe("ui", function() - local child = MiniTest.new_child_neovim({}, { connection_timeout = 30000 }) local SearchBuf, SearchWin, ResultBuf, ResultWin, Namespace, prompt_extmark before_each(function() - child.restart({ "-u", getTestPath() }) - child.lua([[require("hawtkeys").setup({})]]) + require("plenary.reload").reload_module("hawtkeys") + require("hawtkeys").setup({}) end) describe("search", function() before_each(function() - child.lua([[require("hawtkeys.ui").show()]]) + require("plenary.reload").reload_module("hawtkeys") + require("hawtkeys").setup({}) + vim.cmd([[lua require("hawtkeys.ui").show()]]) SearchBuf, SearchWin, ResultBuf, ResultWin, Namespace, prompt_extmark = - unpack(child.lua([[ - local ui = require("hawtkeys.ui") - return { - ui.SearchBuf, - ui.SearchWin, - ui.ResultBuf, - ui.ResultWin, - ui.Namespace, - ui.prompt_extmark - } - ]])) + unpack((function() + local ui = require("hawtkeys.ui") + return { + ui.SearchBuf, + ui.SearchWin, + ui.ResultBuf, + ui.ResultWin, + ui.Namespace, + ui.prompt_extmark, + } + end)()) end) it("should show the search UI", function() - assert(child.api.nvim_buf_is_valid(SearchBuf)) - assert(child.api.nvim_win_is_valid(SearchWin)) + assert(vim.api.nvim_buf_is_valid(SearchBuf)) + assert(vim.api.nvim_win_is_valid(SearchWin)) - assert(child.api.nvim_buf_is_valid(ResultBuf)) - assert(child.api.nvim_win_is_valid(ResultWin)) + assert(vim.api.nvim_buf_is_valid(ResultBuf)) + assert(vim.api.nvim_win_is_valid(ResultWin)) - eq(SearchBuf, child.api.nvim_get_current_buf()) - eq(SearchWin, child.api.nvim_get_current_win()) + eq(SearchBuf, vim.api.nvim_get_current_buf()) + eq(SearchWin, vim.api.nvim_get_current_win()) - local win_config = child.api.nvim_win_get_config(SearchWin) + local win_config = vim.api.nvim_win_get_config(SearchWin) eq("editor", win_config.relative) end) + --TODO: This doesnt work since removing the dependency on mini.test + --[[ it("starts in insert mode", function() + assert(vim.api.nvim_buf_is_valid(SearchBuf)) + assert(vim.api.nvim_win_is_valid(SearchWin)) - it("starts in insert mode", function() - assert(child.api.nvim_buf_is_valid(SearchBuf)) - assert(child.api.nvim_win_is_valid(SearchWin)) - - eq(child.api.nvim_get_current_win(), SearchWin) - eq("i", child.api.nvim_get_mode().mode) + eq(vim.api.nvim_get_current_win(), SearchWin) + eq("i", vim.api.nvim_get_mode().mode) end) - +]] it("should show the hint extmark", function() assert(SearchBuf) assert(prompt_extmark) assert(Namespace) - local extmark_info = child.api.nvim_buf_get_extmark_by_id( + local extmark_info = vim.api.nvim_buf_get_extmark_by_id( SearchBuf, Namespace, prompt_extmark, @@ -78,50 +69,53 @@ describe("ui", function() describe("all", function() before_each(function() - child.lua([[require("hawtkeys.ui").show_all()]]) - ResultBuf, ResultWin, Namespace = unpack(child.lua([[ + require("plenary.reload").reload_module("hawtkeys") + require("hawtkeys").setup({}) + vim.cmd([[lua require("hawtkeys.ui").show_all()]]) + ResultBuf, ResultWin, Namespace = unpack((function() local ui = require("hawtkeys.ui") return { ui.ResultBuf, ui.ResultWin, ui.Namespace, } - ]])) + end)()) end) it("should show the all UI", function() - assert(child.api.nvim_buf_is_valid(ResultBuf)) - assert(child.api.nvim_win_is_valid(ResultWin)) + print(vim.inspect(ResultBuf)) + assert(vim.api.nvim_buf_is_valid(ResultBuf)) + assert(vim.api.nvim_win_is_valid(ResultWin)) - eq(child.api.nvim_get_current_buf(), ResultBuf) - eq(child.api.nvim_get_current_win(), ResultWin) + eq(vim.api.nvim_get_current_buf(), ResultBuf) + eq(vim.api.nvim_get_current_win(), ResultWin) - local win_config = child.api.nvim_win_get_config(ResultWin) + local win_config = vim.api.nvim_win_get_config(ResultWin) eq(win_config.relative, "editor") end) end) describe("dupes", function() before_each(function() - child.lua([[require("hawtkeys.ui").show_dupes()]]) - ResultBuf, ResultWin, Namespace = unpack(child.lua([[ + vim.cmd([[lua require("hawtkeys.ui").show_dupes()]]) + ResultBuf, ResultWin, Namespace = unpack((function() local ui = require("hawtkeys.ui") return { ui.ResultBuf, ui.ResultWin, ui.Namespace, } - ]])) + end)()) end) it("should show the duplicates UI", function() - assert(child.api.nvim_buf_is_valid(ResultBuf)) - assert(child.api.nvim_win_is_valid(ResultWin)) + assert(vim.api.nvim_buf_is_valid(ResultBuf)) + assert(vim.api.nvim_win_is_valid(ResultWin)) - eq(child.api.nvim_get_current_buf(), ResultBuf) - eq(child.api.nvim_get_current_win(), ResultWin) + eq(vim.api.nvim_get_current_buf(), ResultBuf) + eq(vim.api.nvim_get_current_win(), ResultWin) - local win_config = child.api.nvim_win_get_config(ResultWin) + local win_config = vim.api.nvim_win_get_config(ResultWin) eq(win_config.relative, "editor") end) end) diff --git a/tests/minimal_init.lua b/tests/minimal_init.lua index 7d91e65..0cedfbd 100644 --- a/tests/minimal_init.lua +++ b/tests/minimal_init.lua @@ -41,7 +41,6 @@ end local plenary_dir = os.getenv("PLENARY_DIR") or tempdir("plenary.nvim") local treesitter_dir = os.getenv("TREESITTER_DIR") or tempdir("nvim-treesitter") -local mini_dir = os.getenv("MINI_DIR") or tempdir("mini-test") if vim.fn.isdirectory(plenary_dir) == 0 then vim.fn.system({ "git", @@ -58,20 +57,10 @@ if vim.fn.isdirectory(treesitter_dir) == 0 then treesitter_dir, }) end -if vim.fn.isdirectory(mini_dir) == 0 then - vim.fn.system({ - "git", - "clone", - "https://github.com/tris203/mini.test", - mini_dir, - }) -end vim.opt.rtp:append(".") vim.opt.rtp:append(plenary_dir) vim.opt.rtp:append(treesitter_dir) -vim.opt.rtp:append(mini_dir) require("plenary.busted") -require("mini.test").setup() vim.cmd("runtime plugin/plenary.vim") vim.cmd("runtime plugin/treesitter.vim")