diff --git a/lua/cp/test_render.lua b/lua/cp/test_render.lua index aa7acf1..df3d9b3 100644 --- a/lua/cp/test_render.lua +++ b/lua/cp/test_render.lua @@ -7,7 +7,7 @@ local M = {} ---Convert test status to CP terminology with colors ---@param test_case TestCase ---@return StatusInfo -local function get_status_info(test_case) +function M.get_status_info(test_case) if test_case.status == 'pass' then return { text = 'AC', highlight_group = 'CpTestAC' } elseif test_case.status == 'fail' then @@ -36,7 +36,7 @@ function M.render_test_list(test_state) for i, test_case in ipairs(test_state.test_cases) do local is_current = i == test_state.current_index local prefix = is_current and '> ' or ' ' - local status_info = get_status_info(test_case) + local status_info = M.get_status_info(test_case) local status_text = status_info.text ~= '' and status_info.text or '' local line = string.format('%s%d. %s', prefix, i, status_text) diff --git a/spec/diff_spec.lua b/spec/diff_spec.lua index 6fef325..95097ee 100644 --- a/spec/diff_spec.lua +++ b/spec/diff_spec.lua @@ -4,7 +4,8 @@ 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) + table.sort(backends) + assert.same({ 'git', 'vim' }, backends) end) end) @@ -30,7 +31,11 @@ describe('cp.diff', function() describe('is_git_available', function() it('returns true when git command succeeds', function() local mock_system = stub(vim, 'system') - mock_system.returns({ code = 0 }) + mock_system.returns({ + wait = function() + return { code = 0 } + end, + }) local result = diff.is_git_available() assert.is_true(result) @@ -40,7 +45,11 @@ describe('cp.diff', function() it('returns false when git command fails', function() local mock_system = stub(vim, 'system') - mock_system.returns({ code = 1 }) + mock_system.returns({ + wait = function() + return { code = 1 } + end, + }) local result = diff.is_git_available() assert.is_false(result)