mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-14 01:50:27 +00:00
checkpoint: working through a ui test for removing from display
This commit is contained in:
parent
5d6a39c945
commit
b6800cb0ed
@ -108,4 +108,8 @@ function M.get_contents(bufnr)
|
||||
return indices
|
||||
end
|
||||
|
||||
function M.set_contents(bufnr, contents)
|
||||
vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, contents)
|
||||
end
|
||||
|
||||
return M
|
||||
|
@ -1,12 +1,17 @@
|
||||
local utils = require("harpoon2.test.utils")
|
||||
local Buffer = require("harpoon2.buffer")
|
||||
local harpoon = require("harpoon2")
|
||||
|
||||
local eq = assert.are.same
|
||||
local be = utils.before_each(os.tmpname())
|
||||
|
||||
describe("harpoon", function()
|
||||
before_each(utils.before_each(os.tmpname()))
|
||||
before_each(function()
|
||||
be()
|
||||
harpoon = require("harpoon2")
|
||||
end)
|
||||
|
||||
it("open the ui without any items in the list", function()
|
||||
local harpoon = require("harpoon2")
|
||||
harpoon.ui:toggle_quick_menu(harpoon:list())
|
||||
|
||||
local bufnr = harpoon.ui.bufnr
|
||||
@ -22,4 +27,17 @@ describe("harpoon", function()
|
||||
eq(harpoon.ui.bufnr, nil)
|
||||
eq(harpoon.ui.win_id, nil)
|
||||
end)
|
||||
|
||||
it("delete file from list via ui", function()
|
||||
local created_files = utils.fill_list_with_files(3, harpoon:list())
|
||||
eq(harpoon:list():length(), 3)
|
||||
|
||||
harpoon.ui:toggle_quick_menu(harpoon:list())
|
||||
table.remove(created_files, 2)
|
||||
Buffer.set_contents(harpoon.ui.bufnr, created_files)
|
||||
harpoon.ui:toggle_quick_menu()
|
||||
|
||||
eq(harpoon:list():length(), 2)
|
||||
eq(harpoon:list():display(), created_files)
|
||||
end)
|
||||
end)
|
||||
|
@ -42,11 +42,26 @@ function M.create_file(name, contents, row, col)
|
||||
vim.api.nvim_set_current_buf(bufnr)
|
||||
vim.api.nvim_buf_set_text(0, 0, 0, 0, 0, contents)
|
||||
if row then
|
||||
vim.api.nvim_win_set_cursor(0, { row, col })
|
||||
vim.api.nvim_win_set_cursor(0, { row or 1, col or 0 })
|
||||
end
|
||||
|
||||
table.insert(M.created_files, bufnr)
|
||||
return bufnr
|
||||
end
|
||||
|
||||
---@param count number
|
||||
---@param list HarpoonList
|
||||
function M.fill_list_with_files(count, list)
|
||||
local files = {}
|
||||
|
||||
for _ = 1, count do
|
||||
local name = os.tmpname()
|
||||
table.insert(files, name)
|
||||
M.create_file(name, { "test" })
|
||||
list:append()
|
||||
end
|
||||
|
||||
return files
|
||||
end
|
||||
|
||||
return M
|
||||
|
Loading…
x
Reference in New Issue
Block a user