feat(api): add tests for setting terminal ui options

This commit is contained in:
bfredl 2022-04-17 11:05:07 +02:00
parent d63ad42e49
commit 8973768a4e

View File

@ -4,6 +4,7 @@ local clear = helpers.clear
local command = helpers.command local command = helpers.command
local eq = helpers.eq local eq = helpers.eq
local shallowcopy = helpers.shallowcopy local shallowcopy = helpers.shallowcopy
local eval = helpers.eval
describe('UI receives option updates', function() describe('UI receives option updates', function()
local screen local screen
@ -168,3 +169,42 @@ describe('UI receives option updates', function()
it('from startup options with --headless', function() startup_test(true) end) it('from startup options with --headless', function() startup_test(true) end)
it('from startup options with --embed', function() startup_test(false) end) it('from startup options with --embed', function() startup_test(false) end)
end) end)
describe('UI can set terminal option', function()
local screen
before_each(function()
-- by default we implicity "--cmd 'set bg=light'" which ruins everything
clear{args_rm={'--cmd'}}
screen = Screen.new(20,5)
end)
it('term_background', function()
eq('dark', eval '&background')
screen:attach {term_background='light'}
eq('light', eval '&background')
end)
it("term_background but not if 'background' already set by user", function()
eq('dark', eval '&background')
command 'set background=dark'
screen:attach {term_background='light'}
eq('dark', eval '&background')
end)
it('term_name', function()
eq('nvim', eval '&term')
screen:attach {term_name='xterm'}
eq('xterm', eval '&term')
end)
it('term_colors', function()
eq('256', eval '&t_Co')
screen:attach {term_colors=8}
eq('8', eval '&t_Co')
end)
end)