-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8009017
commit 5bb7b8b
Showing
13 changed files
with
130 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
{ | ||
"diagnostics": { | ||
"runtime": { | ||
"version": "LuaJIT" | ||
} | ||
}, | ||
"runtime.version": "LuaJIT", | ||
"workspace.library": [ | ||
"/usr/local/share/nvim/runtime/lua", | ||
"~/.local/share/nvim/lazy/nvim-cmp", | ||
"${3rd}/luv/library", | ||
"${3rd}/luassert/library" | ||
"${3rd}/luassert/library", | ||
"${3rd}/busted/library" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
local common = require("tests.queries.common") | ||
local runner = common.Runner:new("tests/queries/astro/index.astro") | ||
|
||
describe("queries astro:", function() | ||
runner:classes(4) | ||
runner:ranges({ | ||
local spec = { | ||
name = "astro", | ||
provider = "treesitter", | ||
file = "tests/queries/astro/index.astro", | ||
ranges = { | ||
{ 4, 17, 4, 42 }, | ||
{ 6, 12, 6, 26 }, | ||
{ 7, 14, 7, 41 }, | ||
{ 9, 33, 9, 43 }, | ||
}) | ||
end) | ||
}, | ||
} | ||
|
||
require("tests.queries.runner").test(spec) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
local common = require("tests.queries.common") | ||
local runner = common.Runner:new("tests/queries/css/style.css") | ||
|
||
describe("queries css:", function() | ||
runner:classes(2) | ||
runner:ranges({ | ||
local spec = { | ||
name = "css", | ||
provider = "treesitter", | ||
file = "tests/queries/css/style.css", | ||
ranges = { | ||
{ 5, 9, 5, 34 }, | ||
{ 9, 9, 10, 37 }, | ||
}) | ||
end) | ||
}, | ||
} | ||
|
||
require("tests.queries.runner").test(spec) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
local common = require("tests.queries.common") | ||
local runner = common.Runner:new("tests/queries/heex/index.html.heex") | ||
|
||
describe("queries heex:", function() | ||
runner:classes(3) | ||
runner:ranges({ | ||
local spec = { | ||
name = "heex", | ||
provider = "treesitter", | ||
file = "tests/queries/heex/index.html.heex", | ||
ranges = { | ||
{ 0, 12, 0, 27 }, | ||
{ 1, 13, 1, 20 }, | ||
{ 2, 12, 5, 4 }, | ||
}) | ||
end) | ||
}, | ||
} | ||
|
||
require("tests.queries.runner").test(spec) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
local common = require("tests.queries.common") | ||
local runner = common.Runner:new("tests/queries/html/index.html") | ||
|
||
describe("queries html:", function() | ||
runner:classes(2) | ||
runner:ranges({ | ||
local spec = { | ||
name = "html", | ||
provider = "treesitter", | ||
file = "tests/queries/html/index.html", | ||
ranges = { | ||
{ 10, 14, 10, 47 }, | ||
{ 11, 16, 11, 39 }, | ||
}) | ||
end) | ||
}, | ||
} | ||
|
||
require("tests.queries.runner").test(spec) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
local common = require("tests.queries.common") | ||
local runner = common.Runner:new("tests/queries/html/index.html", "htmldjango") | ||
|
||
describe("queries htmldjango:", function() | ||
runner:classes(2) | ||
runner:ranges({ | ||
local spec = { | ||
name = "html", | ||
provider = "treesitter", | ||
file = "tests/queries/html/index.html", | ||
filetype = "htmldjango", | ||
ranges = { | ||
{ 10, 14, 10, 47 }, | ||
{ 11, 16, 11, 39 }, | ||
}) | ||
end) | ||
}, | ||
} | ||
|
||
require("tests.queries.runner").test(spec) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
local common = require("tests.queries.common") | ||
local runner = common.Runner:new("tests/queries/php/index.php") | ||
|
||
describe("queries php:", function() | ||
runner:classes(2) | ||
runner:ranges({ | ||
local spec = { | ||
name = "php", | ||
provider = "treesitter", | ||
file = "tests/queries/php/index.php", | ||
ranges = { | ||
{ 10, 14, 10, 47 }, | ||
{ 11, 16, 11, 39 }, | ||
}) | ||
end) | ||
}, | ||
} | ||
|
||
require("tests.queries.runner").test(spec) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
local M = {} | ||
|
||
local assert = require("luassert") | ||
local classes = require("tailwind-tools.classes") | ||
|
||
---@class TestSpec | ||
---@field name string | ||
---@field provider "treesitter" | "luapattern" | ||
---@field file string | ||
---@field filetype? string | ||
---@field ranges number[][] | ||
|
||
---@param spec TestSpec | ||
M.test = function(spec) | ||
describe(string.format("query %s (%s):", spec.name, spec.provider), function() | ||
assert.same(1, vim.fn.filereadable(spec.file), spec.file .. " is not readable") | ||
|
||
vim.cmd.edit(spec.file) | ||
vim.bo.filetype = spec.filetype or vim.bo.filetype | ||
|
||
local ranges = assert(classes.get_ranges(0), "Expected range list, got nil") | ||
|
||
it( | ||
"Should get class count", | ||
function() assert.same(#ranges, #spec.ranges, "Mismatched class count") end | ||
) | ||
|
||
it("Should get ranges", function() | ||
for i, range in pairs(ranges) do | ||
assert.same(range, spec.ranges[i], "Mismatched range (index = " .. i .. ")") | ||
end | ||
end) | ||
end) | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
local common = require("tests.queries.common") | ||
local runner = common.Runner:new("tests/queries/svelte/test.svelte") | ||
|
||
describe("queries svelte:", function() | ||
runner:classes(3) | ||
runner:ranges({ | ||
local spec = { | ||
name = "svelte", | ||
provider = "treesitter", | ||
file = "tests/queries/svelte/test.svelte", | ||
ranges = { | ||
{ 4, 12, 4, 26 }, | ||
{ 5, 14, 5, 41 }, | ||
{ 8, 17, 8, 27 }, | ||
}) | ||
end) | ||
}, | ||
} | ||
|
||
require("tests.queries.runner").test(spec) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
local common = require("tests.queries.common") | ||
local runner = common.Runner:new("tests/queries/tsx/Component.tsx") | ||
|
||
describe("queries tsx:", function() | ||
runner:classes(3) | ||
runner:ranges({ | ||
local spec = { | ||
name = "tsx", | ||
provider = "treesitter", | ||
file = "tests/queries/tsx/Component.tsx", | ||
ranges = { | ||
{ 6, 19, 7, 55 }, | ||
{ 9, 24, 9, 47 }, | ||
{ 13, 33, 13, 45 }, | ||
}) | ||
end) | ||
}, | ||
} | ||
|
||
require("tests.queries.runner").test(spec) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
local common = require("tests.queries.common") | ||
local runner = common.Runner:new("tests/queries/twig/test.twig") | ||
|
||
describe("queries twig:", function() | ||
runner:classes(3) | ||
runner:ranges({ | ||
local spec = { | ||
name = "twig", | ||
provider = "treesitter", | ||
file = "tests/queries/twig/test.twig", | ||
ranges = { | ||
{ 0, 12, 0, 26 }, | ||
{ 1, 14, 1, 41 }, | ||
{ 4, 17, 4, 27 }, | ||
}) | ||
end) | ||
}, | ||
} | ||
|
||
require("tests.queries.runner").test(spec) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
local common = require("tests.queries.common") | ||
local runner = common.Runner:new("tests/queries/vue/test.vue") | ||
|
||
describe("queries vue:", function() | ||
runner:classes(3) | ||
runner:ranges({ | ||
local spec = { | ||
name = "vue", | ||
provider = "treesitter", | ||
file = "tests/queries/vue/test.vue", | ||
ranges = { | ||
{ 1, 14, 1, 28 }, | ||
{ 2, 16, 2, 43 }, | ||
{ 4, 39, 4, 49 }, | ||
}) | ||
end) | ||
}, | ||
} | ||
|
||
require("tests.queries.runner").test(spec) |