nvim-ts-autotag/tests/renametag_spec.lua

326 lines
9.2 KiB
Lua
Raw Normal View History

2024-05-19 07:01:00 -05:00
local ts = require("nvim-treesitter.configs")
ts.setup({
ensure_installed = _G.ts_filetypes,
highlight = {
2023-12-10 02:01:33 -06:00
use_languagetree = false,
enable = true,
},
fold = { enable = false },
})
2021-03-08 06:19:01 -06:00
local data = {
{
2024-05-19 07:01:00 -05:00
name = "html rename open tag",
filepath = "./sample/index.html",
filetype = "html",
linenr = 10,
key = [[ciwlala]],
before = [[<di|v> dsadsa </div> ]],
after = [[<lala|> dsadsa </lala> ]],
},
{
2024-05-19 07:01:00 -05:00
name = "html rename open tag with attr",
filepath = "./sample/index.html",
filetype = "html",
linenr = 10,
key = [[ciwlala]],
before = [[<di|v class="lla"> dsadsa </div> ]],
after = [[<lala| class="lla"> dsadsa </lala|> ]],
},
{
2024-05-19 07:01:00 -05:00
name = "html rename close tag with attr",
filepath = "./sample/index.html",
filetype = "html",
linenr = 10,
key = [[ciwlala]],
before = [[<div class="lla"> dsadsa </di|v> ]],
after = [[<lala class="lla"> dsadsa </lal|a> ]],
},
{
2024-05-19 07:01:00 -05:00
name = "html not rename close tag on char <",
filepath = "./sample/index.html",
filetype = "html",
linenr = 10,
key = [[i<]],
before = [[<div class="lla"> dsadsa |/button> ]],
after = [[<div class="lla"> dsadsa <|/button> ]],
},
{
2024-05-19 07:01:00 -05:00
name = "html not rename close tag with not valid",
filepath = "./sample/index.html",
filetype = "html",
linenr = 12,
key = [[ciwlala]],
before = {
[[<di|v class="lla" ]],
[[ dsadsa </div>]],
},
after = [[<lala class="lla" ]],
2021-03-13 06:57:34 -06:00
},
-- {
-- only=true,
-- name = "html not rename close tag if it have parent node map with child nod" ,
-- filepath = './sample/index.html',
-- filetype = "html",
-- linenr = 12,
-- key = [[ciwlala]],
-- before = {
-- [[<d|iv> </div>]],
-- [[<div> </div>"]]
-- },
-- after = [[<d|iv> </div>]]
-- },
{
2024-05-19 07:01:00 -05:00
name = "html not rename close tag with not valid",
filepath = "./sample/index.html",
filetype = "html",
linenr = 12,
key = [[ciwlala]],
before = {
[[<div class="lla" </d|iv>]],
},
after = [[<div class="lla" </lala|>]],
2021-03-13 06:57:34 -06:00
},
2021-04-19 06:50:38 -05:00
{
2024-05-19 07:01:00 -05:00
name = "typescriptreact rename open tag",
filepath = "./sample/index.tsx",
filetype = "typescriptreact",
linenr = 12,
key = [[ciwlala]],
before = [[<di|v> dsadsa </div> ]],
after = [[<lala|> dsadsa </lala> ]],
2021-04-19 06:50:38 -05:00
},
2021-05-07 19:34:31 -05:00
{
2024-05-19 07:01:00 -05:00
name = "typescriptreact rename open tag with attr",
filepath = "./sample/index.tsx",
filetype = "typescriptreact",
linenr = 12,
key = [[ciwlala]],
before = [[<di|v class="lla"> dsadsa </div> ]],
after = [[<lala| class="lla"> dsadsa </lala> ]],
},
{
2024-05-19 07:01:00 -05:00
name = "typescriptreact rename close tag with attr",
filepath = "./sample/index.tsx",
filetype = "html",
linenr = 12,
key = [[ciwlala]],
before = [[<div class="lla"> dsadsa </di|v> ]],
after = [[<lala class="lla"> dsadsa </lal|a> ]],
},
{
2024-05-19 07:01:00 -05:00
name = "17 typescriptreact nested indentifer ",
filepath = "./sample/index.tsx",
filetype = "typescriptreact",
linenr = 12,
key = [[ciwlala]],
before = [[<Opt.In|put></Opt.Input> ]],
after = [[<Opt.lala|></Opt.lala> ]],
},
{
2024-05-19 07:01:00 -05:00
name = "18 rename empty node ",
filepath = "./sample/index.tsx",
filetype = "typescriptreact",
linenr = 12,
key = [[ilala]],
before = [[<|><div></div></>]],
after = [[<lala|><div></div></lala>]],
},
{
2024-05-19 07:01:00 -05:00
name = "19 rename start tag on svelte ",
filepath = "./sample/index.svelte",
filetype = "svelte",
linenr = 18,
key = [[ciwlala]],
before = [[<|data></data>]],
after = [[<lala|></lala>]],
2021-05-07 19:34:31 -05:00
},
{
2024-05-19 07:01:00 -05:00
name = "20 rename end tag on svelte ",
filepath = "./sample/index.svelte",
filetype = "svelte",
linenr = 18,
key = [[ciwlala]],
before = [[<span></spa|n>]],
after = [[<lala></lala>]],
},
{
2024-05-19 07:01:00 -05:00
name = "21 rescript rename open tag",
filepath = "./sample/index.res",
filetype = "rescript",
2024-05-19 07:01:00 -05:00
linenr = 12,
key = [[ciwlala]],
before = [[<di|v> dsadsa </div> ]],
after = [[<lala|> dsadsa </lala> ]],
2021-05-07 19:34:31 -05:00
},
2022-02-07 14:05:41 -06:00
{
2024-05-19 07:01:00 -05:00
name = "22 rescript rename open tag with attr",
filepath = "./sample/index.res",
filetype = "rescript",
2024-05-19 07:01:00 -05:00
linenr = 12,
key = [[ciwlala]],
before = [[<di|v class="lla"> dsadsa </div> ]],
after = [[<lala| class="lla"> dsadsa </lala> ]],
2022-02-07 14:05:41 -06:00
},
{
2024-05-19 07:01:00 -05:00
name = "23 rescript rename close tag with attr",
filepath = "./sample/index.res",
filetype = "rescript",
2024-05-19 07:01:00 -05:00
linenr = 12,
key = [[ciwlala]],
before = [[<div class="lla"> dsadsa </di|v> ]],
after = [[<lala class="lla"> dsadsa </lal|a> ]],
2022-02-07 14:05:41 -06:00
},
{
2024-05-19 07:01:00 -05:00
name = "24 test check rename same with parent",
filepath = "./sample/index.tsx",
filetype = "typescriptreact",
linenr = 12,
2024-05-19 07:01:00 -05:00
key = "ciwkey",
before = {
2024-05-19 07:01:00 -05:00
"<Container>",
" <di|v>",
"",
" <span></span>",
"</Container>",
},
after = {
2024-05-19 07:01:00 -05:00
"<Container>",
" <key>",
"",
" <span></span>",
"</Container>",
},
2022-02-07 14:05:41 -06:00
},
{
2024-05-19 07:01:00 -05:00
name = "25 rename start have same node with parent",
filepath = "./sample/index.tsx",
filetype = "typescriptreact",
linenr = 12,
key = [[ciwlala]],
before = {
2024-05-19 07:01:00 -05:00
"<div>",
" <di|v>",
" <span>test </span>",
" </div>",
"</div>",
},
after = {
2024-05-19 07:01:00 -05:00
"<div>",
" <lala>",
" <span>test </span>",
" </lala>",
"</div>",
},
},
{
2024-05-19 07:01:00 -05:00
name = "26 rename should not rename tag on attribute node",
filepath = "./sample/index.tsx",
filetype = "typescriptreact",
linenr = 12,
key = [[ciwlala]],
before = {
2024-05-19 07:01:00 -05:00
"<div>",
'<Navbar className="|a">',
' <div className="flex flex-col">',
' <div className="flex flex-row">',
2024-05-19 07:01:00 -05:00
" </div>",
" </div>",
"</div>",
},
after = {
2024-05-19 07:01:00 -05:00
"<div>",
'<Navbar className="lala">',
' <div className="flex flex-col">',
' <div className="flex flex-row">',
2024-05-19 07:01:00 -05:00
" </div>",
" </div>",
"</div>",
},
},
{
2024-05-19 07:01:00 -05:00
name = "eruby rename open tag",
filepath = "./sample/index.html.erb",
filetype = "eruby",
linenr = 10,
key = [[ciwlala]],
before = [[<di|v> dsadsa </div> ]],
after = [[<lala|> dsadsa </lala> ]],
},
{
2024-05-19 07:01:00 -05:00
name = "eruby rename open tag with attr",
filepath = "./sample/index.html.erb",
filetype = "eruby",
linenr = 10,
key = [[ciwlala]],
before = [[<di|v class="lla"> dsadsa </div> ]],
after = [[<lala| class="lla"> dsadsa </lala|> ]],
},
{
2024-05-19 07:01:00 -05:00
name = "eruby rename close tag with attr",
filepath = "./sample/index.html.erb",
filetype = "eruby",
linenr = 10,
key = [[ciwlala]],
before = [[<div class="lla"> dsadsa </di|v> ]],
after = [[<lala class="lla"> dsadsa </lal|a> ]],
},
{
2024-05-19 07:01:00 -05:00
name = "eruby not rename close tag on char <",
filepath = "./sample/index.html.erb",
filetype = "eruby",
linenr = 10,
key = [[i<]],
before = [[<div class="lla"> dsadsa |/button> ]],
after = [[<div class="lla"> dsadsa <|/button> ]],
},
{
2024-05-19 07:01:00 -05:00
name = "eruby not rename close tag with not valid",
filepath = "./sample/index.html.erb",
filetype = "eruby",
linenr = 12,
key = [[ciwlala]],
before = {
[[<di|v class="lla" ]],
[[ dsadsa </div>]],
},
after = [[<lala class="lla" ]],
},
{
2024-05-19 07:01:00 -05:00
name = "eruby not rename close tag with not valid",
filepath = "./sample/index.html.erb",
filetype = "eruby",
linenr = 12,
key = [[ciwlala]],
before = {
[[<div class="lla" </d|iv>]],
},
after = [[<div class="lla" </lala|>]],
},
{
2024-05-19 07:01:00 -05:00
name = "eruby not rename tag-like ruby string",
filepath = "./sample/index.html.erb",
filetype = "eruby",
linenr = 12,
key = [[ciwlala]],
before = {
[[<%= <div></d|iv> %>]],
},
after = [[<%= <div></lala|> %>]],
},
2021-03-08 06:19:01 -06:00
}
2021-03-08 20:26:36 -06:00
2024-05-19 07:01:00 -05:00
local autotag = require("nvim-ts-autotag")
2021-03-08 20:26:36 -06:00
autotag.test = true
2021-03-08 06:19:01 -06:00
local run_data = _G.Test_filter(data)
2021-03-08 06:19:01 -06:00
2024-05-19 07:01:00 -05:00
describe("[rename tag]", function()
_G.Test_withfile(run_data, {
cursor_add = 0,
before_each = function(value) end,
})
2021-03-08 06:19:01 -06:00
end)