mirror of
https://github.com/stevearc/aerial.nvim
synced 2024-09-16 14:34:08 +02:00
feat: jest support for typescript (#47)
This commit is contained in:
parent
4428a478e7
commit
960cf86d9a
4 changed files with 163 additions and 0 deletions
|
@ -279,6 +279,17 @@ M.typescript = {
|
|||
item.kind = "Function"
|
||||
end
|
||||
end
|
||||
local method = (utils.get_at_path(match, "method") or {}).node
|
||||
local modifier = (utils.get_at_path(match, "modifier") or {}).node
|
||||
local string = (utils.get_at_path(match, "string") or {}).node
|
||||
if method and string then
|
||||
local fn = vim.treesitter.query.get_node_text(method, bufnr) or "<parse error>"
|
||||
if modifier then
|
||||
fn = fn .. "." .. (vim.treesitter.query.get_node_text(modifier, bufnr) or "<parse error>")
|
||||
end
|
||||
local str = vim.treesitter.query.get_node_text(string, bufnr) or "<parse error>"
|
||||
item.name = fn .. " " .. str
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
|
|
|
@ -34,3 +34,38 @@
|
|||
value: (_) @var_type) @type
|
||||
(#set! "kind" "Variable")
|
||||
) @start
|
||||
|
||||
; describe("Unit test")
|
||||
(call_expression
|
||||
function: (identifier) @method @name (#any-of? @method "describe" "it" "test" "afterAll" "afterEach" "beforeAll" "beforeEach")
|
||||
arguments: (arguments
|
||||
(string
|
||||
(string_fragment) @name @string))?
|
||||
(#set! "kind" "Function")
|
||||
) @type
|
||||
|
||||
; test.skip("this test")
|
||||
(call_expression
|
||||
function: (member_expression
|
||||
object: (identifier) @method (#any-of? @method "describe" "it" "test")
|
||||
property: (property_identifier) @modifier (#any-of? @modifier "skip" "todo")
|
||||
) @name
|
||||
arguments: (arguments
|
||||
(string
|
||||
(string_fragment) @name @string))?
|
||||
(#set! "kind" "Function")
|
||||
) @type
|
||||
|
||||
; describe.each([])("Test suite")
|
||||
(call_expression
|
||||
function: (call_expression
|
||||
function: (member_expression
|
||||
object: (identifier) @method (#any-of? @method "describe" "it" "test")
|
||||
property: (property_identifier) @modifier (#any-of? @modifier "each")
|
||||
) @name
|
||||
)
|
||||
arguments: (arguments
|
||||
(string
|
||||
(string_fragment) @name @string))?
|
||||
(#set! "kind" "Function")
|
||||
) @type
|
||||
|
|
|
@ -86,6 +86,109 @@ describe("treesitter ts", function()
|
|||
end_lnum = 16,
|
||||
end_col = 22,
|
||||
},
|
||||
{
|
||||
kind = "Function",
|
||||
name = "describe UnitTest",
|
||||
level = 0,
|
||||
lnum = 18,
|
||||
col = 0,
|
||||
end_lnum = 30,
|
||||
end_col = 2,
|
||||
children = {
|
||||
{
|
||||
kind = "Function",
|
||||
name = "afterAll",
|
||||
level = 1,
|
||||
lnum = 19,
|
||||
col = 2,
|
||||
end_lnum = 19,
|
||||
end_col = 20,
|
||||
},
|
||||
{
|
||||
kind = "Function",
|
||||
name = "afterEach",
|
||||
level = 1,
|
||||
lnum = 20,
|
||||
col = 2,
|
||||
end_lnum = 20,
|
||||
end_col = 21,
|
||||
},
|
||||
{
|
||||
kind = "Function",
|
||||
name = "beforeAll",
|
||||
level = 1,
|
||||
lnum = 21,
|
||||
col = 2,
|
||||
end_lnum = 21,
|
||||
end_col = 21,
|
||||
},
|
||||
{
|
||||
kind = "Function",
|
||||
name = "beforeEach",
|
||||
level = 1,
|
||||
lnum = 22,
|
||||
col = 2,
|
||||
end_lnum = 22,
|
||||
end_col = 22,
|
||||
},
|
||||
{
|
||||
kind = "Function",
|
||||
name = "test should describe the test",
|
||||
level = 1,
|
||||
lnum = 23,
|
||||
col = 2,
|
||||
end_lnum = 23,
|
||||
end_col = 44,
|
||||
},
|
||||
{
|
||||
kind = "Function",
|
||||
name = "it is an alias for test",
|
||||
level = 1,
|
||||
lnum = 24,
|
||||
col = 2,
|
||||
end_lnum = 24,
|
||||
end_col = 38,
|
||||
},
|
||||
{
|
||||
kind = "Function",
|
||||
name = "test.skip skip this test",
|
||||
level = 1,
|
||||
lnum = 25,
|
||||
col = 2,
|
||||
end_lnum = 25,
|
||||
end_col = 39,
|
||||
},
|
||||
{
|
||||
kind = "Function",
|
||||
name = "test.todo this is a todo",
|
||||
level = 1,
|
||||
lnum = 26,
|
||||
col = 2,
|
||||
end_lnum = 26,
|
||||
end_col = 29,
|
||||
},
|
||||
{
|
||||
kind = "Function",
|
||||
name = "describe.each Test Suite",
|
||||
level = 1,
|
||||
lnum = 27,
|
||||
col = 2,
|
||||
end_lnum = 29,
|
||||
end_col = 4,
|
||||
children = {
|
||||
{
|
||||
kind = "Function",
|
||||
name = "test.each runs multiple times",
|
||||
level = 2,
|
||||
lnum = 28,
|
||||
col = 4,
|
||||
end_lnum = 28,
|
||||
end_col = 50,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end)
|
||||
end)
|
||||
|
|
|
@ -14,3 +14,17 @@ const fn_3 = () => {};
|
|||
|
||||
const const_var = 'value';
|
||||
let let_var = 'value';
|
||||
|
||||
describe("UnitTest", () => {
|
||||
afterAll(() => {});
|
||||
afterEach(() => {});
|
||||
beforeAll(() => {});
|
||||
beforeEach(() => {});
|
||||
test("should describe the test", () => {});
|
||||
it("is an alias for test", () => {});
|
||||
test.skip("skip this test", () => {});
|
||||
test.todo("this is a todo");
|
||||
describe.each([])("Test Suite", () => {
|
||||
test.each([])("runs multiple times", () => {});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue