local common = require("lua-tests.neopyter.common")
local query = require("nvim-treesitter.query")

describe("register", function()
    before_each(function()
        require("neopyter.treesitter").setup()
        require("neopyter.treesitter").load_query("textobjects")
    end)
    it("predicate", function()
        require("neopyter.treesitter").setup()
        local ret = vim.iter(vim.treesitter.query.list_predicates()):find("match-cellseparator?")
        assert.not_nil(ret)
    end)
    it("directive", function()
        require("neopyter.treesitter").setup()
        local ret = vim.iter(vim.treesitter.query.list_directives()):find("make-range-include-whitespace!")
        assert.not_nil(ret)
    end)
end)

describe("match-cellseparator", function()
    before_each(function()
        require("neopyter.treesitter").setup()
        require("neopyter.treesitter").load_query("textobjects")
    end)
    it("base", function()
        local code = "# %%"
        local buf = common.load_buffer(code)
        local nodes = query.get_capture_matches(buf, "@cellseparator", "textobjects")
        assert.is_equal(1, #nodes)
    end)
end)
