Add plenary tests to neovim check

main
Ensar Sarajčić 2022-05-05 18:07:01 +02:00
parent 306c7ed92d
commit c2db3f7758
4 changed files with 33 additions and 1 deletions

View File

@ -314,6 +314,8 @@ check_neovim: check_os
@nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerInstall'
@echo "Doing a basic neovim startup and quit"
@nvim --headless -c 'set display-=msgsep' -c 'quitall'
@echo "Running plenary tests"
@nvim --headless -c 'PlenaryBustedDirectory symlinks/config/nvim/lua/tests'
.PHONY: run_tests
run_tests: check_os

View File

@ -13,3 +13,7 @@ vim.keymap.set("n", "<Leader>tf", ":TestFile<CR>", opts)
vim.keymap.set("n", "<Leader>ts", ":TestSuite<CR>", opts)
vim.keymap.set("n", "<Leader>tl", ":TestLast<CR>", opts)
vim.keymap.set("n", "<Leader>tg", ":TestVisit<CR>", opts)
vim.api.nvim_create_user_command("PlenaryTestFile", function()
require("plenary.test_harness").test_directory(vim.fn.expand("%:p"))
end, {})

View File

@ -57,7 +57,7 @@ end
-- Copies current branches PR url to system clipboard
function M.copy_pr_url(...)
vim.cmd('let @+ = "' .. get_pr_url(...) .. '"')
vim.fn.setreg("+", get_pr_url(...))
end
-- Opens current banches PR url in default browser
@ -77,4 +77,9 @@ function M.checkout_branch(branch)
vim.cmd("Git checkout " .. branch)
end
-- Deletes a branch
function M.delete_branch(branch)
vim.cmd("Git branch -d " .. branch)
end
return M

View File

@ -0,0 +1,21 @@
local fugitive_extensions = require("esensar.fugitive_extensions")
describe("fugitive extensions:", function()
describe("copy_pr_url", function()
before_each(function()
fugitive_extensions.create_branch("test")
end)
after_each(function()
fugitive_extensions.checkout_branch("main")
fugitive_extensions.delete_branch("test")
end)
it("copies PR url to main branch by default", function()
fugitive_extensions.copy_pr_url()
assert.are.same("https://github.com/esensar/dotfiles/compare/test?expand=1", vim.fn.getreg("+"))
end)
it("copies PR url to passed branch", function()
fugitive_extensions.copy_pr_url("dev")
assert.are.same("https://github.com/esensar/dotfiles/compare/dev...test?expand=1", vim.fn.getreg("+"))
end)
end)
end)