repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by bugabinga
neovim/tests/bugabinga/statusline_spec.lua
Rawlocal statusline = require('bugabinga.statusline')
local icon = require('std.icon')
describe('statusline', function()
describe('git_component', function()
local initial_cwd
before_each(function()
initial_cwd = vim.uv.cwd()
statusline._get_cache().git_branch = {}
end)
after_each(function()
statusline._get_cache().git_branch = {}
end)
it('returns empty string on first call (async loading)', function()
local result = statusline.git_component()
assert.is_equal('', result)
end)
it('returns cached branch string when available', function()
local fake_branch = icon.branch .. ' test-branch'
statusline._get_cache().git_branch[initial_cwd] = fake_branch
local result = statusline.git_component()
assert.is_equal(fake_branch, result)
end)
it('DirChanged clears git branch cache (manual test)', function()
-- DirChanged is tested manually since the event isn't reliably
-- fireable in headless test environments.
end)
end)
end)