highlight_spec.lua (2169B)
1 local t = require('test.testutil') 2 local n = require('test.functional.testnvim')() 3 local Screen = require('test.functional.ui.screen') 4 5 local eq, command = t.eq, n.command 6 local clear = n.clear 7 local eval, exc_exec = n.eval, n.exc_exec 8 local exec = n.exec 9 local fn = n.fn 10 local api = n.api 11 12 describe(':highlight', function() 13 before_each(function() 14 clear() 15 local _ = Screen.new() 16 end) 17 18 it('invalid color name', function() 19 eq( 20 'Vim(highlight):E421: Color name or number not recognized: ctermfg=#181818', 21 exc_exec('highlight normal ctermfg=#181818') 22 ) 23 eq( 24 'Vim(highlight):E421: Color name or number not recognized: ctermbg=#181818', 25 exc_exec('highlight normal ctermbg=#181818') 26 ) 27 end) 28 29 it('invalid group name', function() 30 eq('Vim(highlight):E411: Highlight group not found: foo', exc_exec('highlight foo')) 31 end) 32 33 it('"Normal" foreground with red', function() 34 eq('', eval('synIDattr(hlID("Normal"), "fg", "cterm")')) 35 command('highlight normal ctermfg=red') 36 eq('9', eval('synIDattr(hlID("Normal"), "fg", "cterm")')) 37 end) 38 39 it('"Normal" background with red', function() 40 eq('', eval('synIDattr(hlID("Normal"), "bg", "cterm")')) 41 command('highlight normal ctermbg=red') 42 eq('9', eval('synIDattr(hlID("Normal"), "bg", "cterm")')) 43 end) 44 45 it('only the last underline style takes effect #22371', function() 46 command('highlight NonText gui=underline,undercurl') 47 eq('', eval('synIDattr(hlID("NonText"), "underline", "gui")')) 48 eq('1', eval('synIDattr(hlID("NonText"), "undercurl", "gui")')) 49 command('highlight NonText gui=undercurl,underline') 50 eq('', eval('synIDattr(hlID("NonText"), "undercurl", "gui")')) 51 eq('1', eval('synIDattr(hlID("NonText"), "underline", "gui")')) 52 end) 53 54 it('clear', function() 55 api.nvim_set_var('colors_name', 'foo') 56 eq(1, fn.exists('g:colors_name')) 57 command('hi clear') 58 eq(0, fn.exists('g:colors_name')) 59 api.nvim_set_var('colors_name', 'foo') 60 eq(1, fn.exists('g:colors_name')) 61 exec([[ 62 func HiClear() 63 hi clear 64 endfunc 65 ]]) 66 fn.HiClear() 67 eq(0, fn.exists('g:colors_name')) 68 end) 69 end)