canola.nvim/tests/regression_spec.lua
2023-01-18 00:21:04 -08:00

34 lines
1.1 KiB
Lua

require("plenary.async").tests.add_to_env()
local oil = require("oil")
local test_util = require("tests.test_util")
a.describe("regression tests", function()
after_each(function()
test_util.reset_editor()
end)
-- see https://github.com/stevearc/oil.nvim/issues/25
a.it("can edit dirs that will be renamed to an existing buffer", function()
vim.cmd.edit({ args = { "README.md" } })
vim.cmd.vsplit()
vim.cmd.edit({ args = { "%:p:h" } })
assert.equals("oil", vim.bo.filetype)
vim.cmd.wincmd({ args = { "p" } })
assert.equals("markdown", vim.bo.filetype)
vim.cmd.edit({ args = { "%:p:h" } })
a.util.sleep(10)
assert.equals("oil", vim.bo.filetype)
end)
-- https://github.com/stevearc/oil.nvim/issues/37
a.it("places the cursor on correct entry when opening on file", function()
vim.cmd.edit({ args = { "." } })
a.util.sleep(10)
local entry = oil.get_cursor_entry()
assert.not_equals("README.md", entry and entry.name)
vim.cmd.edit({ args = { "README.md" } })
oil.open()
a.util.sleep(10)
entry = oil.get_cursor_entry()
assert.equals("README.md", entry and entry.name)
end)
end)