zk.vim/spec/zk.vim_spec.rb

45 lines
1.6 KiB
Ruby
Raw Normal View History

2023-12-11 13:25:28 +00:00
require 'vimrunner'
vim = Vimrunner.start
vim.add_plugin(File.expand_path('../..', __FILE__), 'plugin/zkvim.vim')
describe "zk.vim" do
after(:all) do
vim.kill
end
describe "zkvim#create_link" do
it "returns a correctly-formatted link when given a title and id" do
expect(vim.command('echo zkvim#create_link("Title", "id")')).to eq("[Title]<id>")
end
end
describe "zkvim#create_append_link_command" do
it "inserts a link using a NORMAL mode append command" do
expect(vim.command('echo zkvim#create_append_link_command("Title", "id")')).to eq("normal! a[Title]<id>")
end
end
describe "zkvim#get_new_zettel_id" do
it "returns the pathname of a new zettel" do
expect(vim.command('echo zkvim#get_new_zettel_id()')).to match("/home/viciouscirce/dox/zettelkasten//[[:digit:]]{12}")
end
end
describe "zkvim#get_zettel_title" do
it "returns the title of the zettel when given a fzf selection" do
expect(vim.command('echo zkvim#get_zettel_title("/home/viciouscirce/dox/zettelkasten//20230527091457 | # Ruby")')).to eq("Ruby")
end
end
describe "zkvim#get_zettel_id" do
it "returns the id of the zettel when given a fzf selection" do
expect(vim.command('echo zkvim#get_zettel_id("/home/viciouscirce/dox/zettelkasten//20230527091457 | # Ruby")')).to eq("20230527091457")
end
it "returns the id of the zettel when given a zettel filepath" do
expect(vim.command('echo zkvim#get_zettel_id("/home/viciouscirce/dox/zettelkasten//20230527091457 ")')).to eq("20230527091457")
end
end
end