go.nvim/lua/tests/go_comment_spec.lua

34 lines
1.1 KiB
Lua
Raw Normal View History

2021-03-10 12:15:06 +00:00
local eq = assert.are.same
2023-01-28 06:08:09 +00:00
local busted = require('plenary/busted')
local cur_dir = vim.fn.expand('%:p:h')
describe('should get nodes ', function()
2021-08-24 04:53:37 +00:00
_GO_NVIM_CFG.verbose = true
2023-01-28 06:08:09 +00:00
_GO_NVIM_CFG.comment_placeholder = ''
2021-03-10 12:15:06 +00:00
2023-01-28 06:08:09 +00:00
local status = require('plenary.reload').reload_module('go.nvim')
status = require('plenary.reload').reload_module('nvim-treesitter/nvim-treesitter')
2021-03-10 12:15:06 +00:00
2023-01-28 06:08:09 +00:00
local name = vim.fn.tempname() .. '.go'
print('tmp:' .. name)
2021-08-24 04:53:37 +00:00
--
2023-01-28 06:08:09 +00:00
local path = cur_dir .. '/lua/tests/fixtures/ts/playlist.go' -- %:p:h ? %:p
2021-08-24 04:53:37 +00:00
local lines = vim.fn.readfile(path)
vim.fn.writefile(lines, name)
local cmd = "silent exe 'e " .. name .. "'"
vim.cmd(cmd)
2021-03-10 12:15:06 +00:00
2023-01-28 06:08:09 +00:00
local bufn = vim.fn.bufnr('')
it('should get struct playlist and generate comments', function()
vim.fn.setpos('.', { bufn, 20, 14, 0 })
local query = require('go.comment').gen(20, 14)
eq('// createPlaylist function  ', query)
2021-08-24 04:53:37 +00:00
end)
2021-03-10 12:15:06 +00:00
2023-01-28 06:08:09 +00:00
it('should get struct playlist and generate comments', function()
vim.fn.setpos('.', { bufn, 14, 4, 0 })
local query = require('go.comment').gen(14, 4)
eq('// playlist struct  ', query)
2021-08-24 04:53:37 +00:00
end)
end)