2021-03-10 12:15:06 +00:00
|
|
|
local eq = assert.are.same
|
|
|
|
|
|
|
|
local busted = require("plenary/busted")
|
|
|
|
local cur_dir = vim.fn.expand("%:p:h")
|
2021-08-24 04:53:37 +00:00
|
|
|
describe("should get nodes ", function()
|
|
|
|
_GO_NVIM_CFG.verbose = true
|
|
|
|
_GO_NVIM_CFG.comment_placeholder = " "
|
2021-03-10 12:15:06 +00:00
|
|
|
|
2021-08-24 04:53:37 +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
|
|
|
|
2021-08-24 04:53:37 +00:00
|
|
|
local name = vim.fn.tempname() .. ".go"
|
|
|
|
print("tmp:" .. name)
|
|
|
|
--
|
|
|
|
local path = cur_dir .. "/lua/tests/fixtures/ts/playlist.go" -- %:p:h ? %:p
|
|
|
|
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
|
|
|
|
2021-08-24 04:53:37 +00:00
|
|
|
local bufn = vim.fn.bufnr("")
|
|
|
|
it("should get struct playlist and generate comments", function()
|
2022-07-06 04:30:13 +00:00
|
|
|
vim.fn.setpos(".", { bufn, 20, 14, 0 })
|
2021-08-24 04:53:37 +00:00
|
|
|
local query = require("go.comment").gen(20, 14)
|
|
|
|
eq("// createPlaylist function ", query)
|
|
|
|
end)
|
2021-03-10 12:15:06 +00:00
|
|
|
|
2021-08-24 04:53:37 +00:00
|
|
|
it("should get struct playlist and generate comments", function()
|
2022-07-06 04:30:13 +00:00
|
|
|
vim.fn.setpos(".", { bufn, 14, 4, 0 })
|
2021-08-24 04:53:37 +00:00
|
|
|
local query = require("go.comment").gen(14, 4)
|
2022-07-06 17:12:24 +00:00
|
|
|
eq("// playlist struct ", query)
|
2021-08-24 04:53:37 +00:00
|
|
|
end)
|
|
|
|
end)
|