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