robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
2.2 KiB72 linesraw
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()
16  before_each(function()
17    clear()
18    local _ = Screen.new()
19  end)
20
21  it('invalid color name', function()
22    eq(
23      'Vim(highlight):E421: Color name or number not recognized: ctermfg=#181818',
24      pcall_err(command, 'highlight normal ctermfg=#181818')
25    )
26    eq(
27      'Vim(highlight):E421: Color name or number not recognized: ctermbg=#181818',
28      pcall_err(command, 'highlight normal ctermbg=#181818')
29    )
30  end)
31
32  it('invalid group name', function()
33    eq('Vim(highlight):E411: Highlight group not found: foo', pcall_err(command, 'highlight foo'))
34  end)
35
36  it('"Normal" foreground with red', function()
37    eq('', eval('synIDattr(hlID("Normal"), "fg", "cterm")'))
38    command('highlight normal ctermfg=red')
39    eq('9', eval('synIDattr(hlID("Normal"), "fg", "cterm")'))
40  end)
41
42  it('"Normal" background with red', function()
43    eq('', eval('synIDattr(hlID("Normal"), "bg", "cterm")'))
44    command('highlight normal ctermbg=red')
45    eq('9', eval('synIDattr(hlID("Normal"), "bg", "cterm")'))
46  end)
47
48  it('only the last underline style takes effect #22371', function()
49    command('highlight NonText gui=underline,undercurl')
50    eq('', eval('synIDattr(hlID("NonText"), "underline", "gui")'))
51    eq('1', eval('synIDattr(hlID("NonText"), "undercurl", "gui")'))
52    command('highlight NonText gui=undercurl,underline')
53    eq('', eval('synIDattr(hlID("NonText"), "undercurl", "gui")'))
54    eq('1', eval('synIDattr(hlID("NonText"), "underline", "gui")'))
55  end)
56
57  it('clear', function()
58    api.nvim_set_var('colors_name', 'foo')
59    eq(1, fn.exists('g:colors_name'))
60    command('hi clear')
61    eq(0, fn.exists('g:colors_name'))
62    api.nvim_set_var('colors_name', 'foo')
63    eq(1, fn.exists('g:colors_name'))
64    exec([[
65      func HiClear()
66        hi clear
67      endfunc
68    ]])
69    fn.HiClear()
70    eq(0, fn.exists('g:colors_name'))
71  end)
72end)