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()
it('returns vim and git backends', function()
local backends = diff.get_available_backends()
assert.same({'vim', 'git'}, backends)
assert.same({ 'vim', 'git' }, backends)
end)
end)
@ -81,7 +81,7 @@ describe('cp.diff', function()
local backend = diff.get_backend('vim')
local result = backend.render('expected', 'actual')
assert.same({'actual'}, result.content)
assert.same({ 'actual' }, result.content)
assert.is_nil(result.highlights)
end)
end)
@ -140,7 +140,7 @@ describe('cp.diff', function()
local backend = diff.get_backend('git')
local result = backend.render('same', 'same')
assert.same({'same'}, result.content)
assert.same({ 'same' }, result.content)
assert.same({}, result.highlights)
mock_system:revert()
@ -153,7 +153,11 @@ describe('cp.diff', function()
describe('render_diff', function()
it('uses best available backend', function()
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)
diff.render_diff('expected', 'actual', 'vim')

View file

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