Regenerate nvim config
This commit is contained in:
@ -0,0 +1,69 @@
|
||||
local config = require 'trim.config'
|
||||
|
||||
local assert = require 'luassert'
|
||||
|
||||
describe('default config', function()
|
||||
config.setup()
|
||||
local actual = config.get()
|
||||
|
||||
it('has empty ft_blocklist', function()
|
||||
assert.are.equal(#actual.ft_blocklist, 0)
|
||||
end)
|
||||
|
||||
it('has trim_on_write enabled', function()
|
||||
assert.is_true(actual.trim_on_write)
|
||||
end)
|
||||
|
||||
it('has trim_trailing enabled', function()
|
||||
assert.is_true(actual.trim_trailing)
|
||||
end)
|
||||
|
||||
it('has trim_last_line enabled', function()
|
||||
assert.is_true(actual.trim_last_line)
|
||||
end)
|
||||
|
||||
it('has trim_first_line enabled', function()
|
||||
assert.is_true(actual.trim_first_line)
|
||||
end)
|
||||
|
||||
it('has 3 patterns', function()
|
||||
assert.are.equal(#actual.patterns, 3)
|
||||
assert.are.equal(actual.patterns[1], [[%s/\s\+$//e]])
|
||||
assert.are.equal(actual.patterns[2], [[%s/\%^\n\+//]])
|
||||
assert.are.equal(actual.patterns[3], [[%s/\($\n\s*\)\+\%$//]])
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('config', function()
|
||||
config.setup {
|
||||
ft_blocklist = { 'markdown' },
|
||||
trim_on_write = false,
|
||||
trim_trailing = false,
|
||||
trim_last_line = false,
|
||||
trim_first_line = false,
|
||||
patterns = { [[%s/\(\n\n\)\n\+/\1/]] },
|
||||
}
|
||||
|
||||
local actual = config.get()
|
||||
|
||||
it('is overwritten', function()
|
||||
assert(#actual.ft_blocklist, 1)
|
||||
assert(actual.ft_blocklist[1], 'markdown')
|
||||
assert.is_not_true(actual.trim_on_write)
|
||||
assert.is_not_true(actual.trim_trailing)
|
||||
assert.is_not_true(actual.trim_last_line)
|
||||
assert.is_not_true(actual.trim_first_line)
|
||||
|
||||
assert.are.equal(#actual.patterns, 1)
|
||||
assert.are.equal(actual.patterns[1], [[%s/\(\n\n\)\n\+/\1/]])
|
||||
end)
|
||||
|
||||
it('keeps compatability', function()
|
||||
config.setup { disable = { 'lua' } }
|
||||
local actual = config.get()
|
||||
|
||||
-- disable is deprecated, use ft_blocklist instead
|
||||
assert.are.equal(#actual.ft_blocklist, 1)
|
||||
assert.are.equal(actual.ft_blocklist[1], 'lua')
|
||||
end)
|
||||
end)
|
||||
@ -0,0 +1,7 @@
|
||||
describe('init', function()
|
||||
it('has correct environment for tests', function()
|
||||
for _, path in ipairs { 'config', 'data', 'cache', 'state' } do
|
||||
assert(vim.fn.stdpath(path):find('.tests/' .. path))
|
||||
end
|
||||
end)
|
||||
end)
|
||||
36
config/neovim/store/lazy-plugins/trim.nvim/tests/init.lua
Normal file
36
config/neovim/store/lazy-plugins/trim.nvim/tests/init.lua
Normal file
@ -0,0 +1,36 @@
|
||||
local M = {}
|
||||
|
||||
function M.root(root)
|
||||
local f = debug.getinfo(1, 'S').source:sub(2)
|
||||
return vim.fn.fnamemodify(f, ':p:h:h') .. '/' .. (root or '')
|
||||
end
|
||||
|
||||
---@param plugin string
|
||||
function M.load(plugin)
|
||||
local name = plugin:match '.*/(.*)'
|
||||
local package_root = M.root '.tests/site/pack/deps/start/'
|
||||
if not vim.loop.fs_stat(package_root .. name) then
|
||||
print('Installing ' .. plugin)
|
||||
vim.fn.mkdir(package_root, 'p')
|
||||
vim.fn.system {
|
||||
'git',
|
||||
'clone',
|
||||
'--depth=1',
|
||||
'https://github.com/' .. plugin .. '.git',
|
||||
package_root .. '/' .. name,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function M.setup()
|
||||
vim.cmd [[set runtimepath=$VIMRUNTIME]]
|
||||
vim.opt.runtimepath:append(M.root())
|
||||
vim.opt.packpath = { M.root '.tests/site' }
|
||||
M.load 'nvim-lua/plenary.nvim'
|
||||
vim.env.XDG_CONFIG_HOME = M.root '.tests/config'
|
||||
vim.env.XDG_DATA_HOME = M.root '.tests/data'
|
||||
vim.env.XDG_STATE_HOME = M.root '.tests/state'
|
||||
vim.env.XDG_CACHE_HOME = M.root '.tests/cache'
|
||||
end
|
||||
|
||||
M.setup()
|
||||
Reference in New Issue
Block a user