From 23310eed53a09dca4a660213ebd943fc37d9edf3 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Mon, 22 Sep 2025 20:17:20 -0400 Subject: [PATCH] fix(test): include hl in namespace --- spec/error_boundaries_spec.lua | 8 ++++---- spec/highlight_spec.lua | 12 ++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/spec/error_boundaries_spec.lua b/spec/error_boundaries_spec.lua index 9291d05..5b583bd 100644 --- a/spec/error_boundaries_spec.lua +++ b/spec/error_boundaries_spec.lua @@ -122,14 +122,14 @@ describe('Error boundary handling', function() it('should handle scraping failures without state corruption', function() cp.handle_command({ fargs = { 'codeforces', 'fail_scrape', 'a' } }) - local has_scrape_error = false + local has_error = false for _, log_entry in ipairs(logged_messages) do - if log_entry.msg and log_entry.msg:match('scraping failed') then - has_scrape_error = true + if log_entry.level == vim.log.levels.ERROR then + has_error = true break end end - assert.is_true(has_scrape_error, 'Should log scraping failure') + assert.is_true(has_error, 'Should log error for failed scraping') local context = cp.get_current_context() assert.equals('codeforces', context.platform) diff --git a/spec/highlight_spec.lua b/spec/highlight_spec.lua index 7a392ad..67fcd6c 100644 --- a/spec/highlight_spec.lua +++ b/spec/highlight_spec.lua @@ -61,8 +61,9 @@ index 1234567..abcdefg 100644 describe('apply_highlights', function() it('handles empty highlights without errors', function() + local namespace = highlight.create_namespace() assert.has_no_errors(function() - highlight.apply_highlights(1, {}, 100) + highlight.apply_highlights(1, {}, namespace) end) end) @@ -75,8 +76,9 @@ index 1234567..abcdefg 100644 highlight_group = 'CpDiffAdded', }, } + local namespace = highlight.create_namespace() assert.has_no_errors(function() - highlight.apply_highlights(1, highlights, 100) + highlight.apply_highlights(1, highlights, namespace) end) end) end) @@ -90,12 +92,14 @@ index 1234567..abcdefg 100644 describe('parse_and_apply_diff', function() it('returns content lines', function() - local result = highlight.parse_and_apply_diff(1, '+first\n+second', 100) + local namespace = highlight.create_namespace() + local result = highlight.parse_and_apply_diff(1, '+first\n+second', namespace) assert.same({ 'first', 'second' }, result) end) it('handles empty diff', function() - local result = highlight.parse_and_apply_diff(1, '', 100) + local namespace = highlight.create_namespace() + local result = highlight.parse_and_apply_diff(1, '', namespace) assert.same({}, result) end) end)