diff options
author | Matthieu Coudron <mattator@gmail.com> | 2017-08-27 00:33:36 +0200 |
---|---|---|
committer | Matthieu Coudron <mattator@gmail.com> | 2017-09-30 11:43:26 +0900 |
commit | e3a2cca3878f44252eccdc1918cc8854145de860 (patch) | |
tree | b589f76c6c0e5a7a0519d2f01b6de68653f27507 /test/functional/api/highlight_spec.lua | |
parent | ba7277cfb4e2556f246446d06b53f3427f28130f (diff) | |
download | rneovim-e3a2cca3878f44252eccdc1918cc8854145de860.tar.gz rneovim-e3a2cca3878f44252eccdc1918cc8854145de860.tar.bz2 rneovim-e3a2cca3878f44252eccdc1918cc8854145de860.zip |
Increased test coverage for RGB and cterm
Diffstat (limited to 'test/functional/api/highlight_spec.lua')
-rw-r--r-- | test/functional/api/highlight_spec.lua | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua index 1aacfaed03..a5d3871d13 100644 --- a/test/functional/api/highlight_spec.lua +++ b/test/functional/api/highlight_spec.lua @@ -8,47 +8,53 @@ local ok = helpers.ok local meths = helpers.meths -describe('highlight api', function() +describe('highlight api',function() + local expected_rgb = { background = Screen.colors.Yellow, + foreground = Screen.colors.Red, + special = Screen.colors.Blue, + bold = true, + } + + local expected_cterm = { background = 10, + underline = true, + } before_each(function() - clear('--cmd', 'set termguicolors') + clear() + command("hi NewHighlight cterm=underline ctermbg=green guifg=red guibg=yellow guisp=blue gui=bold") end) it("nvim_get_hl_by_id", function() - local expected_hl = { background = Screen.colors.Yellow, - foreground = Screen.colors.Red, - special = Screen.colors.Blue - } + local hl_id = eval("hlID('NewHighlight')") - command('hi NewHighlight guifg=red guibg=yellow guisp=blue') + eq(expected_cterm, nvim("get_hl_by_id", hl_id)) - local hl_id = eval("hlID('NewHighlight')") - eq(expected_hl, nvim("get_hl_by_id", hl_id)) + command('set termguicolors') + hl_id = eval("hlID('NewHighlight')") + eq(expected_rgb, nvim("get_hl_by_id", hl_id)) - -- assume there is no hl with 30000 + -- assume there is no hl with id 30000 local err, emsg = pcall(meths.get_hl_by_id, 30000) eq(false, err) ok(string.find(emsg, 'Invalid highlight id') ~= nil) end) it("nvim_get_hl_by_name", function() - local expected_hl = { background = Screen.colors.Yellow, + local expected_normal = { background = Screen.colors.Yellow, foreground = Screen.colors.Red } -- test "Normal" hl defaults eq({}, nvim("get_hl_by_name", 'Normal')) - command('hi NewHighlight guifg=red guibg=yellow') - eq(expected_hl, nvim("get_hl_by_name", 'NewHighlight')) + eq(expected_cterm, nvim("get_hl_by_name", 'NewHighlight')) + command('set termguicolors') + eq(expected_rgb, nvim("get_hl_by_name", 'NewHighlight')) command('hi Normal guifg=red guibg=yellow') - eq(expected_hl, nvim("get_hl_by_name", 'Normal')) + eq(expected_normal, nvim("get_hl_by_name", 'Normal')) + local err, emsg = pcall(meths.get_hl_by_name , 'unknown_highlight') eq(false, err) ok(string.find(emsg, 'Invalid highlight name') ~= nil) end) - - - end) - |