local ignored = require('std.ignored') require('bugabinga.treesitter') local function deep_copy(t) local copy = {} for k, v in pairs(t) do copy[k] = v end return copy end local function table_eq(a, b) if type(a) ~= 'table' or type(b) ~= 'table' then return a == b end for k, v in pairs(a) do if not table_eq(v, b[k]) then return false end end for k, v in pairs(b) do if not table_eq(v, a[k]) then return false end end return true end describe('is_ignored', function() local original_filetypes local original_filetypes_kv local original_filetypes_patterns before_each(function() original_filetypes = deep_copy(ignored.filetypes) original_filetypes_kv = deep_copy(ignored.filetypes_kv) if ignored.filetypes_patterns then original_filetypes_patterns = deep_copy(ignored.filetypes_patterns) end end) after_each(function() ignored.filetypes = original_filetypes ignored.filetypes_kv = original_filetypes_kv ignored.filetypes_patterns = original_filetypes_patterns end) describe('correctness', function() local function expect_ignored(match, expected) local result = BugabingaTreesitter.is_ignored(match) assert.is.equal(expected, result, string.format('is_ignored(%q) = %s, expected %s', match, tostring(result), tostring(expected))) end it('returns true for exact match "help"', function() expect_ignored('help', true) end) it('returns true for exact match "oil"', function() expect_ignored('oil', true) end) it('returns true for exact match "lazy"', function() expect_ignored('lazy', true) end) it('returns true for pattern match "gitcommit" (matches ^git.*)', function() expect_ignored('gitcommit', true) end) it('returns true for pattern match "git" (matches ^git.*)', function() expect_ignored('git', true) end) it('returns false for non-ignored filetype "lua"', function() expect_ignored('lua', false) end) it('returns false for non-ignored filetype "rust"', function() expect_ignored('rust', false) end) it('returns false for non-ignored filetype "python"', function() expect_ignored('python', false) end) it('returns false for "text" (caller handles it separately)', function() expect_ignored('text', false) end) it('returns false for empty string', function() expect_ignored('', false) end) end) end)