feat: removed some duplicate tests that are present in the ui.

This commit is contained in:
Michael Paulson 2023-12-01 13:56:46 -07:00
parent 689778b3aa
commit 1e041f13b1
2 changed files with 1 additions and 106 deletions

View File

@ -17,7 +17,7 @@ describe("config", function()
}) })
vim.api.nvim_win_set_cursor(0, { 3, 1 }) vim.api.nvim_win_set_cursor(0, { 3, 1 })
local item = config_item.add() local item = config_item.add(config_item)
eq(item, { eq(item, {
value = "/tmp/harpoon-test", value = "/tmp/harpoon-test",
context = { context = {

View File

@ -105,109 +105,4 @@ describe("harpoon", function()
}) })
end) end)
it("ui - display resolve", function()
harpoon:setup({
default = {
display = function(item)
-- split string on /
local parts = vim.split(item.value, "/")
return parts[#parts]
end,
},
})
local file_names = {
"/tmp/harpoon-test-1",
"/tmp/harpoon-test-2",
"/tmp/harpoon-test-3",
"/tmp/harpoon-test-4",
}
local contents = { "foo", "bar", "baz", "qux" }
local bufnrs = {}
local list = harpoon:list()
for _, v in ipairs(file_names) do
table.insert(bufnrs, utils.create_file(v, contents))
harpoon:list():append()
end
local displayed = list:display()
eq(displayed, {
"harpoon-test-1",
"harpoon-test-2",
"harpoon-test-3",
"harpoon-test-4",
})
table.remove(displayed, 3)
table.remove(displayed, 2)
list:resolve_displayed(displayed)
eq(list.items, {
{ value = file_names[1], context = { row = 4, col = 2 } },
{ value = file_names[4], context = { row = 4, col = 2 } },
})
end)
it("ui - display resolve", function()
local file_names = {
"/tmp/harpoon-test-1",
"/tmp/harpoon-test-2",
"/tmp/harpoon-test-3",
"/tmp/harpoon-test-4",
}
local contents = { "foo", "bar", "baz", "qux" }
local bufnrs = {}
local list = harpoon:list()
for _, v in ipairs(file_names) do
table.insert(bufnrs, utils.create_file(v, contents))
harpoon:list():append()
end
local displayed = list:display()
eq(displayed, {
"/tmp/harpoon-test-1",
"/tmp/harpoon-test-2",
"/tmp/harpoon-test-3",
"/tmp/harpoon-test-4",
})
table.remove(displayed, 3)
table.remove(displayed, 2)
table.insert(displayed, "/tmp/harpoon-test-other-file-1")
table.insert(displayed, "/tmp/harpoon-test-other-file-2")
list:resolve_displayed(displayed)
eq({
{ value = file_names[1], context = { row = 4, col = 2 } },
{ value = file_names[4], context = { row = 4, col = 2 } },
{
value = "/tmp/harpoon-test-other-file-1",
context = { row = 1, col = 0 },
},
{
value = "/tmp/harpoon-test-other-file-2",
context = { row = 1, col = 0 },
},
}, list.items)
table.remove(displayed, 3)
table.insert(displayed, "/tmp/harpoon-test-4")
list:resolve_displayed(displayed)
eq({
{ value = file_names[1], context = { row = 4, col = 2 } },
{ value = file_names[4], context = { row = 4, col = 2 } },
{
value = "/tmp/harpoon-test-other-file-2",
context = { row = 1, col = 0 },
},
}, list.items)
end)
end) end)