fix(ci): format

This commit is contained in:
Barrett Ruth 2025-09-19 13:19:30 -04:00
parent 21407be376
commit 526c82cac0
2 changed files with 25 additions and 24 deletions

View file

@ -4,7 +4,7 @@ describe('cp.diff', function()
describe('get_available_backends', function() describe('get_available_backends', function()
it('returns vim and git backends', function() it('returns vim and git backends', function()
local backends = diff.get_available_backends() local backends = diff.get_available_backends()
assert.same({'vim', 'git'}, backends) assert.same({ 'vim', 'git' }, backends)
end) end)
end) end)
@ -81,7 +81,7 @@ describe('cp.diff', function()
local backend = diff.get_backend('vim') local backend = diff.get_backend('vim')
local result = backend.render('expected', 'actual') local result = backend.render('expected', 'actual')
assert.same({'actual'}, result.content) assert.same({ 'actual' }, result.content)
assert.is_nil(result.highlights) assert.is_nil(result.highlights)
end) end)
end) end)
@ -140,7 +140,7 @@ describe('cp.diff', function()
local backend = diff.get_backend('git') local backend = diff.get_backend('git')
local result = backend.render('same', 'same') local result = backend.render('same', 'same')
assert.same({'same'}, result.content) assert.same({ 'same' }, result.content)
assert.same({}, result.highlights) assert.same({}, result.highlights)
mock_system:revert() mock_system:revert()
@ -153,7 +153,11 @@ describe('cp.diff', function()
describe('render_diff', function() describe('render_diff', function()
it('uses best available backend', function() it('uses best available backend', function()
local mock_get_best = spy.on(diff, 'get_best_backend') local mock_get_best = spy.on(diff, 'get_best_backend')
local mock_backend = { render = function() return {} end } local mock_backend = {
render = function()
return {}
end,
}
mock_get_best.returns(mock_backend) mock_get_best.returns(mock_backend)
diff.render_diff('expected', 'actual', 'vim') diff.render_diff('expected', 'actual', 'vim')

View file

@ -14,13 +14,13 @@ index 1234567..abcdefg 100644
-goodbye -goodbye
]] ]]
local result = highlight.parse_git_diff(diff_output) local result = highlight.parse_git_diff(diff_output)
assert.same({'hello', 'world'}, result.content) assert.same({ 'hello', 'world' }, result.content)
end) end)
it('processes added lines', function() it('processes added lines', function()
local diff_output = '+hello w{+o+}rld' local diff_output = '+hello w{+o+}rld'
local result = highlight.parse_git_diff(diff_output) local result = highlight.parse_git_diff(diff_output)
assert.same({'hello world'}, result.content) assert.same({ 'hello world' }, result.content)
assert.equals(1, #result.highlights) assert.equals(1, #result.highlights)
assert.equals('CpDiffAdded', result.highlights[1].highlight_group) assert.equals('CpDiffAdded', result.highlights[1].highlight_group)
end) end)
@ -28,13 +28,13 @@ index 1234567..abcdefg 100644
it('ignores removed lines', function() it('ignores removed lines', function()
local diff_output = 'hello\n-removed line\n+kept line' local diff_output = 'hello\n-removed line\n+kept line'
local result = highlight.parse_git_diff(diff_output) local result = highlight.parse_git_diff(diff_output)
assert.same({'hello', 'kept line'}, result.content) assert.same({ 'hello', 'kept line' }, result.content)
end) end)
it('handles unchanged lines', function() it('handles unchanged lines', function()
local diff_output = 'unchanged line\n+added line' local diff_output = 'unchanged line\n+added line'
local result = highlight.parse_git_diff(diff_output) local result = highlight.parse_git_diff(diff_output)
assert.same({'unchanged line', 'added line'}, result.content) assert.same({ 'unchanged line', 'added line' }, result.content)
end) end)
it('sets correct line numbers', function() it('sets correct line numbers', function()
@ -72,20 +72,17 @@ index 1234567..abcdefg 100644
line = 0, line = 0,
col_start = 5, col_start = 5,
col_end = 10, col_end = 10,
highlight_group = 'CpDiffAdded' highlight_group = 'CpDiffAdded',
} },
} }
highlight.apply_highlights(bufnr, highlights, namespace) highlight.apply_highlights(bufnr, highlights, namespace)
assert.spy(mock_extmark).was_called_with( assert.spy(mock_extmark).was_called_with(bufnr, namespace, 0, 5, {
bufnr, namespace, 0, 5, end_col = 10,
{ hl_group = 'CpDiffAdded',
end_col = 10, priority = 100,
hl_group = 'CpDiffAdded', })
priority = 100
}
)
mock_extmark:revert() mock_extmark:revert()
end) end)
@ -96,8 +93,8 @@ index 1234567..abcdefg 100644
line = 0, line = 0,
col_start = 0, col_start = 0,
col_end = 5, col_end = 5,
highlight_group = 'CpDiffAdded' highlight_group = 'CpDiffAdded',
} },
} }
highlight.apply_highlights(1, highlights, 100) highlight.apply_highlights(1, highlights, 100)
@ -140,8 +137,8 @@ index 1234567..abcdefg 100644
local result = highlight.parse_and_apply_diff(bufnr, diff_output, namespace) local result = highlight.parse_and_apply_diff(bufnr, diff_output, namespace)
assert.same({'hello world'}, result) assert.same({ 'hello world' }, result)
assert.spy(mock_set_lines).was_called_with(bufnr, 0, -1, false, {'hello world'}) assert.spy(mock_set_lines).was_called_with(bufnr, 0, -1, false, { 'hello world' })
assert.spy(mock_apply).was_called() assert.spy(mock_apply).was_called()
mock_set_lines:revert() mock_set_lines:revert()
@ -153,7 +150,7 @@ index 1234567..abcdefg 100644
highlight.parse_and_apply_diff(1, '+test line', 100) highlight.parse_and_apply_diff(1, '+test line', 100)
assert.spy(mock_set_lines).was_called_with(1, 0, -1, false, {'test line'}) assert.spy(mock_set_lines).was_called_with(1, 0, -1, false, { 'test line' })
mock_set_lines:revert() mock_set_lines:revert()
end) end)
@ -168,7 +165,7 @@ index 1234567..abcdefg 100644
it('returns content lines', function() it('returns content lines', function()
local result = highlight.parse_and_apply_diff(1, '+first\n+second', 100) local result = highlight.parse_and_apply_diff(1, '+first\n+second', 100)
assert.same({'first', 'second'}, result) assert.same({ 'first', 'second' }, result)
end) end)
end) end)
end) end)