local stub = require("luassert.stub")

describe("Neovim commands:", function()
	before_each(function()
		vim.cmd("set ft=yaml")
	end)

	after_each(function()
		vim.cmd(":bw!")
	end)

	it("YAMLView calls Lua function", function()
		local view = stub(require("yaml_nvim"), "view")
		vim.cmd("YAMLView")
		assert.stub(view).was_called_with()
	end)

	it("YAMLYank calls Lua function for default register", function()
		local yank = stub(require("yaml_nvim"), "yank")
		vim.cmd("YAMLYank")
		assert.stub(yank).was_called_with()
	end)

	it("YAMLYank calls Lua function for custom register", function()
		local yank = stub(require("yaml_nvim"), "yank")
		vim.cmd("YAMLYank 8")
		assert.stub(yank).was_called_with("8")
	end)

	it("YAMLYankKey calls Lua function for default register", function()
		local yank_key = stub(require("yaml_nvim"), "yank_key")
		vim.cmd("YAMLYankKey")
		assert.stub(yank_key).was_called_with()
	end)

	it("YAMLYankKey calls Lua function for custom register", function()
		local yank_key = stub(require("yaml_nvim"), "yank_key")
		vim.cmd("YAMLYankKey 8")
		assert.stub(yank_key).was_called_with("8")
	end)

	it("YAMLYankValue calls Lua function for default register", function()
		local yank_value = stub(require("yaml_nvim"), "yank_value")
		vim.cmd("YAMLYankValue")
		assert.stub(yank_value).was_called_with()
	end)

	it("YAMLYankValue calls Lua function for custom register", function()
		local yank_value = stub(require("yaml_nvim"), "yank_value")
		vim.cmd("YAMLYankValue 8")
		assert.stub(yank_value).was_called_with("8")
	end)

	it("YAMLHighlight calls Lua function for highlighting", function()
		local highlight = stub(require("yaml_nvim"), "highlight")
		vim.cmd("YAMLHighlight worldcup.intro")
		assert.stub(highlight).was_called_with("worldcup.intro")
	end)

	it("YAMLRemoveHighlight calls Lua function for removing highlight", function()
		local remove = stub(require("yaml_nvim"), "remove_highlight")
		vim.cmd("YAMLRemoveHighlight")
		assert.stub(remove).was_called_with()
	end)

	it("YAMLQuickfix calls Lua function", function()
		local qf = stub(require("yaml_nvim"), "quickfix")
		vim.cmd("YAMLQuickfix")
		assert.stub(qf).was_called_with()
	end)

	it("YAMLSnacks calls Lua function", function()
		local snacks = stub(require("yaml_nvim"), "snacks")
		vim.cmd("YAMLSnacks")
		assert.stub(snacks).was_called_with()
	end)

	it("YAMLTelescope calls Lua function", function()
		local telescope = stub(require("yaml_nvim"), "telescope")
		vim.cmd("YAMLTelescope")
		assert.stub(telescope).was_called_with()
	end)

	it("YAMLFzFLua calls Lua function", function()
		local fzf_lua = stub(require("yaml_nvim"), "fzf_lua")
		vim.cmd("YAMLFzfLua")
		assert.stub(fzf_lua).was_called_with()
	end)
end)
