fix: fix flaky test
This commit is contained in:
parent
7aeb239a6a
commit
9509ae0fee
5 changed files with 38 additions and 33 deletions
|
|
@ -11,7 +11,7 @@ a.describe("Alternate buffer", function()
|
|||
a.it("sets previous buffer as alternate", function()
|
||||
vim.cmd.edit({ args = { "foo" } })
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd("BufReadPost")
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
vim.cmd.edit({ args = { "bar" } })
|
||||
assert.equals("foo", vim.fn.expand("#"))
|
||||
end)
|
||||
|
|
@ -19,7 +19,7 @@ a.describe("Alternate buffer", function()
|
|||
a.it("sets previous buffer as alternate when editing url file", function()
|
||||
vim.cmd.edit({ args = { "foo" } })
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd("BufReadPost")
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
local readme = fs.join(vim.fn.getcwd(), "README.md")
|
||||
vim.cmd.edit({ args = { "oil://" .. fs.os_to_posix_path(readme) } })
|
||||
-- We're gonna jump around to 2 different buffers
|
||||
|
|
@ -32,7 +32,7 @@ a.describe("Alternate buffer", function()
|
|||
a.it("sets previous buffer as alternate when editing oil://", function()
|
||||
vim.cmd.edit({ args = { "foo" } })
|
||||
vim.cmd.edit({ args = { "oil://" .. fs.os_to_posix_path(vim.fn.getcwd()) } })
|
||||
test_util.wait_for_autocmd("BufReadPost")
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
vim.cmd.edit({ args = { "bar" } })
|
||||
assert.equals("foo", vim.fn.expand("#"))
|
||||
end)
|
||||
|
|
@ -41,7 +41,7 @@ a.describe("Alternate buffer", function()
|
|||
vim.cmd.edit({ args = { "foo" } })
|
||||
vim.cmd.edit({ args = { "bar" } })
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd("BufReadPost")
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
vim.cmd.edit({ args = { "bar" } })
|
||||
assert.equals("foo", vim.fn.expand("#"))
|
||||
end)
|
||||
|
|
@ -50,7 +50,7 @@ a.describe("Alternate buffer", function()
|
|||
vim.cmd.edit({ args = { "foo" } })
|
||||
vim.cmd.edit({ args = { "bar" } })
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd("BufReadPost")
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
oil.close()
|
||||
assert.equals("bar", vim.fn.expand("%"))
|
||||
assert.equals("foo", vim.fn.expand("#"))
|
||||
|
|
@ -59,13 +59,13 @@ a.describe("Alternate buffer", function()
|
|||
a.it("sets previous buffer as alternate after multi-dir hops", function()
|
||||
vim.cmd.edit({ args = { "foo" } })
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd("BufReadPost")
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd("BufReadPost")
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd("BufReadPost")
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd("BufReadPost")
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
vim.cmd.edit({ args = { "bar" } })
|
||||
assert.equals("foo", vim.fn.expand("#"))
|
||||
end)
|
||||
|
|
@ -73,7 +73,7 @@ a.describe("Alternate buffer", function()
|
|||
a.it("sets previous buffer as alternate when inside oil buffer", function()
|
||||
vim.cmd.edit({ args = { "foo" } })
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd("BufReadPost")
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
assert.equals("foo", vim.fn.expand("#"))
|
||||
vim.cmd.edit({ args = { "bar" } })
|
||||
assert.equals("foo", vim.fn.expand("#"))
|
||||
|
|
@ -84,28 +84,28 @@ a.describe("Alternate buffer", function()
|
|||
a.it("preserves alternate when traversing oil dirs", function()
|
||||
vim.cmd.edit({ args = { "foo" } })
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd("BufReadPost")
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
assert.equals("foo", vim.fn.expand("#"))
|
||||
vim.wait(1000, function()
|
||||
return oil.get_cursor_entry()
|
||||
end, 10)
|
||||
vim.api.nvim_win_set_cursor(0, { 1, 1 })
|
||||
oil.select()
|
||||
test_util.wait_for_autocmd("BufReadPost")
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
assert.equals("foo", vim.fn.expand("#"))
|
||||
end)
|
||||
|
||||
a.it("preserves alternate when opening preview", function()
|
||||
vim.cmd.edit({ args = { "foo" } })
|
||||
oil.open()
|
||||
test_util.wait_for_autocmd("BufReadPost")
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
assert.equals("foo", vim.fn.expand("#"))
|
||||
vim.wait(1000, function()
|
||||
return oil.get_cursor_entry()
|
||||
end, 10)
|
||||
vim.api.nvim_win_set_cursor(0, { 1, 1 })
|
||||
oil.select({ preview = true })
|
||||
test_util.wait_for_autocmd("BufReadPost")
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
assert.equals("foo", vim.fn.expand("#"))
|
||||
end)
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ a.describe("Alternate buffer", function()
|
|||
a.it("sets previous buffer as alternate", function()
|
||||
vim.cmd.edit({ args = { "foo" } })
|
||||
oil.open_float()
|
||||
test_util.wait_for_autocmd("BufReadPost")
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
-- This is lazy, but testing the actual select logic is more difficult. We can simply
|
||||
-- replicate it by closing the current window and then doing the edit
|
||||
vim.api.nvim_win_close(0, true)
|
||||
|
|
@ -125,7 +125,7 @@ a.describe("Alternate buffer", function()
|
|||
vim.cmd.edit({ args = { "foo" } })
|
||||
vim.cmd.edit({ args = { "bar" } })
|
||||
oil.open_float()
|
||||
test_util.wait_for_autocmd("BufReadPost")
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
-- This is lazy, but testing the actual select logic is more difficult. We can simply
|
||||
-- replicate it by closing the current window and then doing the edit
|
||||
vim.api.nvim_win_close(0, true)
|
||||
|
|
@ -137,7 +137,7 @@ a.describe("Alternate buffer", function()
|
|||
vim.cmd.edit({ args = { "foo" } })
|
||||
vim.cmd.edit({ args = { "bar" } })
|
||||
oil.open_float()
|
||||
test_util.wait_for_autocmd("BufReadPost")
|
||||
test_util.wait_for_autocmd({ "User", pattern = "OilEnter" })
|
||||
oil.close()
|
||||
assert.equals("foo", vim.fn.expand("#"))
|
||||
end)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue