(renderer) add more tests; fix bugs in text-change
All checks were successful
NeoVim tests / code-quality (push) Successful in 1m21s

This commit is contained in:
2025-09-07 18:05:38 -06:00
parent 06e6b88391
commit 2ea6c02c69
3 changed files with 129 additions and 42 deletions

View File

@@ -201,6 +201,41 @@ describe('Renderer', function()
assert.are.same(buf:all():text(), 'bleh')
assert.are.same(captured_changed_text, 'bleh')
vim.fn.setreg('"', '')
vim.cmd [[normal! ggdG]]
-- We'll call the handler ourselves:
r:_on_text_changed()
assert.are.same(buf:all():text(), '')
assert.are.same(captured_changed_text, '')
end)
withbuf({}, function()
local Buffer = require 'u.buffer'
local buf = Buffer.current()
local r = R.Renderer.new(0)
--- @type string?
local captured_changed_text = nil
r:render {
'prefix:',
R.h('text', {
on_change = function(txt) captured_changed_text = txt end,
}, {
'one',
}),
'suffix',
}
vim.fn.setreg('"', 'bleh')
vim.api.nvim_win_set_cursor(0, { 1, 9 })
vim.cmd [[normal! vhhd]]
-- For some reason, the autocmd does not fire in the busted environment.
-- We'll call the handler ourselves:
r:_on_text_changed()
assert.are.same(buf:all():text(), 'prefix:suffix')
assert.are.same(captured_changed_text, '')
end)
end)