highlight_spec.lua 2.1 KB

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