refactor: try to add unit test

This commit is contained in:
JuanZoran 2023-03-22 14:37:44 +08:00
parent 8be4fb7303
commit f63574026a
7 changed files with 27 additions and 20 deletions

View File

@ -6,7 +6,9 @@
],
"Lua.diagnostics.globals": [
"vim",
"user_conf"
"user_conf",
"describe",
"it"
],
"Lua.workspace.checkThirdParty": false
}

View File

@ -55,7 +55,6 @@ return {
fallback_message = '{{notfound}} 翻译超时或没有找到相关的翻译',
auto_resize = true,
-- strict_sentence_width = false,
-- strict = false, -- TODO :No Width limit when str is a sentence
padding = 10, -- padding for hover window width
keymaps = {
pageup = '[[',

View File

@ -10,6 +10,7 @@ local function set_frontend_keymap(frontend)
local keymap_opts = {
silent = true,
-- expr = true,
-- nowait = true,
}
for action, key in pairs(frontend.opts.keymaps) do

View File

@ -111,7 +111,6 @@ function window:resize(opts)
end
end
---Try to close window with animation?
function window:try_close()
local close_animation = self.animation.close
@ -133,8 +132,9 @@ end
---Set window local highlight group
---@param name string
---@param opts table highlight config
function window:set_hl(name, opts)
api.nvim_set_hl(self.ns, name, opts)
---@param ns integer namespace
function window:set_hl(name, opts, ns)
api.nvim_set_hl(ns, name, opts)
end
---Open window with animation?
@ -184,11 +184,20 @@ local default_opts = {
---@field buffer TransBuffer attached buffer object
---@field win_opts table window config [**When open**]
---@field winid integer window handle
---@field ns integer namespace for highlight
---@field enter boolean cursor should [enter] window when open
---@field animation
---|{open: string | boolean, close: string | boolean, interval: integer} Hover Window Animation
-- local win_opt = {
-- zindex = zindex,
-- width = width,
-- height = height,
-- col = col,
-- row = row,
-- border = border,
-- title = title,
-- relative = relative,
-- }
---Create new window
---@param opts TransWindowOpts window config
@ -206,13 +215,3 @@ end
---@class Trans
---@field window TransWindow
return window
-- local win_opt = {
-- zindex = zindex,
-- width = width,
-- height = height,
-- col = col,
-- row = row,
-- border = border,
-- title = title,
-- relative = relative,
-- }

View File

@ -74,7 +74,6 @@ function M:init_window(opts)
opts = opts or {}
local m_opts = self.opts
local option = {
ns = self.ns,
buffer = self.buffer,
animation = m_opts.animation,
}
@ -179,9 +178,7 @@ end
---@param data TransData
---@overload fun(result:TransResult)
function M:process(data)
if self.pin then
return
end
if self.pin then return end
local result, name = data:get_available_result()
if not result then

5
lua/test/demo_spec.lua Normal file
View File

@ -0,0 +1,5 @@
describe('Test Demo', function()
it('should work', function()
print('hello')
end)
end)

4
makefile Normal file
View File

@ -0,0 +1,4 @@
.PHONE: test
test:
nvim -headless -c 'TODO: '