-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests Neovim commands correctly calls Lua functions
- Loading branch information
Showing
1 changed file
with
46 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,65 @@ | ||
describe("commands", function() | ||
local stub = require("luassert.stub") | ||
|
||
describe("Neovim commands:", function() | ||
before_each(function() | ||
vim.cmd(":e tests/sample.yaml") | ||
require("yaml_nvim") | ||
vim.cmd("set ft=yaml") | ||
end) | ||
|
||
after_each(function() | ||
vim.cmd(":bw!") | ||
end) | ||
|
||
it("yanks key to the default register", function() | ||
vim.cmd(":YAMLYankKey") | ||
assert.are.equal(vim.fn.getreg('"'), "worldcup") | ||
it("YAMLView calls Lua function", function() | ||
local view = stub(require("yaml_nvim"), "view") | ||
vim.cmd("YAMLView") | ||
assert.stub(view).was_called_with() | ||
end) | ||
|
||
it("yanks key to a custom register", function() | ||
vim.cmd(":YAMLYankKey 7") | ||
assert.are.equal(vim.fn.getreg("7"), "worldcup") | ||
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("yanks value to the default register", function() | ||
require("yaml_nvim") | ||
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) | ||
|
||
vim.cmd(":e sample.yaml") | ||
vim.cmd("norm 10j") | ||
vim.cmd(":YAMLYankValue") | ||
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) | ||
|
||
assert(vim.fn.getreg('"'), "7") | ||
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("yanks value to a custom register", function() | ||
require("yaml_nvim") | ||
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) | ||
|
||
vim.cmd(":e sample.yaml") | ||
vim.cmd("norm 10j") | ||
vim.cmd(":YAMLYankValue 7") | ||
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("YAMLQuickfix calls Lua function", function() | ||
local qf = stub(require("yaml_nvim"), "quickfix") | ||
vim.cmd("YAMLQuickfix") | ||
assert.stub(qf).was_called_with() | ||
end) | ||
|
||
assert(vim.fn.getreg("7"), "7") | ||
it("YAMLTelescope calls Lua function", function() | ||
local telescope = stub(require("yaml_nvim"), "telescope") | ||
vim.cmd("YAMLTelescope") | ||
assert.stub(telescope).was_called_with() | ||
end) | ||
end) |