Skip to content

Commit

Permalink
chore: remove unused vimfn.lua (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikavilpas committed Oct 16, 2024
1 parent a495b7e commit 81c9b1e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 47 deletions.
10 changes: 0 additions & 10 deletions lua/yazi/vimfn.lua

This file was deleted.

22 changes: 0 additions & 22 deletions spec/yazi/no_open_dir_spec.lua

This file was deleted.

37 changes: 22 additions & 15 deletions spec/yazi/open_dir_with_defaults_spec.lua
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
local assert = require("luassert")
local mock = require("luassert.mock")

local api_mock = mock(require("yazi.vimfn"))

local plugin = require("yazi")

describe(
"when the user has not set open_for_directories and uses the defaults",
function()
after_each(function()
mock.clear(api_mock)
end)
describe("open_for_directories", function()
local hijack_netrw = mock(require("yazi.hijack_netrw"), true)
before_each(function()
mock.clear(hijack_netrw)
end)

it("sets up hijack_netrw when `open_for_directories` has been set", function()
plugin.setup({ open_for_directories = true })

-- instead of netrw opening, yazi should open
vim.api.nvim_command("edit /")

assert.spy(hijack_netrw.hijack_netrw).was_called(1)
end)

it("does not show yazi when a directory is opened", function()
---@diagnostic disable-next-line: missing-fields
plugin.setup()
it(
"does not set up hijack_netrw when `open_for_directories` is falsy",
function()
plugin.setup({ open_for_directories = false })

-- instead of netrw opening, yazi should open
vim.api.nvim_command("edit /")

assert.stub(api_mock.termopen).was_not_called()
end)
end
)
assert.spy(hijack_netrw.hijack_netrw).was_not_called()
end
)
end)

0 comments on commit 81c9b1e

Please sign in to comment.