zettelkasten.nvim/lua/zettelkasten/options_spec.lua
Marty Oehme ece30350c2
Refactor options to separate file
Options were previously set ad-hoc in the initialize function, but
re-set and overwritten at various places.

Options now live in one central module (options.lua), where they
directly access the neovim options set, and re-access them on any run.

That means options can be changed while the plugin is running and it
will use their newer versions, without requiring any re-initialization.
2020-10-30 16:04:23 +01:00

31 lines
1.2 KiB
Lua

local opt = require 'zettelkasten.options'
before_each(function() _G.vim = {g = {}, b = {}} end)
after_each(function() _G.vim = nil end)
describe("zettel options", function()
it("should return the global zettel extension if set in vim", function()
_G.vim.g.zettel_extension = ".myextension"
assert.same(".myextension", opt.zettel().extension)
end)
it("should return the buffer zettel extension if set in vim", function()
_G.vim.b.zettel_extension = ".mybufextension"
assert.same(".mybufextension", opt.zettel().extension)
end)
it("should return the default zettel extension if not set in vim",
function() assert.same(".md", opt.zettel().extension) end)
end)
describe("zettel options", function()
it("should return the global anchor separator if set in vim", function()
_G.vim.g.zettel_anchor_separator = "SEPARATE"
assert.same("SEPARATE", opt.anchor().separator)
end)
it("should return the buffer anchor separator if set in vim", function()
_G.vim.b.zettel_anchor_separator = "--"
assert.same("--", opt.anchor().separator)
end)
it("should return the default anchor separator if not set in vim",
function() assert.same("_", opt.anchor().separator) end)
end)