fugitive: remove old fugitive test

As mentioned by @tpope, remove the old test for the autoloaded function
fugitivie#head() and instead use consistently FugitiveHead() everywhere

[delete] %bd command

[add] init.vimspec

[update] init.vimspec

[add] parts.vim

[add] section.vimspec

[add] themes.vimspec

[add] util.vimspec

[delete] vim-vspec
This commit is contained in:
Christian Brabandt
2022-05-21 21:57:01 +02:00
committed by kazukazuinaina
parent 9fad2c3fc4
commit 1a7d546448
19 changed files with 404 additions and 776 deletions

View File

@@ -1,7 +1,4 @@
Describe extensions_tabline.vim
Before all
:%bd
End
It should use a tabline
e! file1

109
test/init.vimspec Normal file
View File

@@ -0,0 +1,109 @@
Describe init.vim
function! s:clear()
for key in s:sections
unlet! g:airline_section_{key}
endfor
endfunction
let s:sections = ['a', 'b', 'c', 'gutter', 'x', 'y', 'z', 'warning']
call airline#init#bootstrap()
Before each
call s:clear()
call airline#init#sections()
End
It section a should have mode, paste, spell, iminsert
Assert Match(g:airline_section_a, 'mode')
Assert Match(g:airline_section_a, 'paste')
Assert Match(g:airline_section_a, 'spell')
Assert Match(g:airline_section_a, 'iminsert')
End
It section b should be blank because no extensions are installed
Assert Equals(g:airline_section_b, '')
End
It section c should be file and coc_status
set noautochdir
call airline#init#sections()
Assert Equals(g:airline_section_c, '%<%f%m %#__accent_red#%{airline#util#wrap(airline#parts#readonly(),0)}%#__restore__#%#__accent_bold#%#__restore__#%#__accent_bold#%#__restore__#')
End
It section c should be path and coc_status
set autochdir
call s:clear()
call airline#init#sections()
Assert Equals(g:airline_section_c, '%<%F%m %#__accent_red#%{airline#util#wrap(airline#parts#readonly(),0)}%#__restore__#%#__accent_bold#%#__restore__#%#__accent_bold#%#__restore__#')
End
It section x should be filetype
Assert Equals(g:airline_section_x, '%#__accent_bold#%#__restore__#%{airline#util#prepend("",0)}%{airline#util#prepend("",0)}%{airline#util#prepend("",0)}%{airline#util#prepend("",0)}%{airline#util#prepend("",0)}%{airline#util#wrap(airline#parts#filetype(),0)}')
End
It section y should be fenc and ff
Assert Equals(g:airline_section_y, '%{airline#util#wrap(airline#parts#ffenc(),0)}')
End
It section z should be line numbers
Assert Match(g:airline_section_z, '%p%%')
Assert Match(g:airline_section_z, '%l')
Assert Match(g:airline_section_z, '%v')
End
It section gutter should be blank unless csv extension is installed
" Note: the csv extension uses only the window local variable
Assert Equals(g:airline_section_gutter, '%=')
End
It section warning should be blank
Assert Match(g:airline_section_warning, '')
End
It should not redefine sections already defined
for s in s:sections
let g:airline_section_{s} = s
endfor
call airline#init#bootstrap()
for s in s:sections
Assert Equals(g:airline_section_{s}, s)
endfor
End
It all default statusline extensions should be blank
Assert Equals(airline#parts#get('ale_error_count').raw, '')
Assert Equals(airline#parts#get('ale_warning_count').raw, '')
Assert Equals(airline#parts#get('lsp_error_count').raw, '')
Assert Equals(airline#parts#get('lsp_warning_count').raw, '')
Assert Equals(airline#parts#get('nvimlsp_error_count').raw, '')
Assert Equals(airline#parts#get('nvimlsp_warning_count').raw, '')
Assert Equals(airline#parts#get('hunks').raw, '')
Assert Equals(airline#parts#get('branch').raw, '')
Assert Equals(airline#parts#get('eclim').raw, '')
Assert Equals(airline#parts#get('neomake_error_count').raw, '')
Assert Equals(airline#parts#get('neomake_warning_count').raw, '')
Assert Equals(airline#parts#get('obsession').raw, '')
Assert Equals(airline#parts#get('syntastic-err').raw, '')
Assert Equals(airline#parts#get('syntastic-warn').raw, '')
Assert Equals(airline#parts#get('tagbar').raw , '')
Assert Equals(airline#parts#get('whitespace').raw, '')
Assert Equals(airline#parts#get('windowswap').raw , '')
Assert Equals(airline#parts#get('ycm_error_count').raw, '')
Assert Equals(airline#parts#get('ycm_warning_count').raw, '')
Assert Equals(airline#parts#get('languageclient_error_count').raw, '')
Assert Equals(airline#parts#get('languageclient_warning_count').raw, '')
Assert Equals(airline#parts#get('coc_status').raw, '')
Assert Equals(airline#parts#get('coc_current_function').raw, '')
Assert Equals(airline#parts#get('vista').raw, '')
Assert Equals(airline#parts#get('coc_warning_count').raw, '')
Assert Equals(airline#parts#get('coc_error_count').raw, '')
Assert Equals(airline#parts#get('battery').raw, '')
End
it should not redefine parts already defined
call airline#parts#define_raw('linenr', 'bar')
call s:clear()
call airline#init#sections()
Assert Match(g:airline_section_z, 'bar')
End
End

58
test/parts.vimspec Normal file
View File

@@ -0,0 +1,58 @@
Describe parts.vim
It overwrItes existing values
call airline#parts#define('foo', { 'test': '123' })
Assert Equals(airline#parts#get('foo').test, '123')
call airline#parts#define('foo', { 'test': '321' })
Assert Equals(airline#parts#get('foo').test, '321')
End
It can define a function part
call airline#parts#define_function('func', 'bar')
Assert Equals(airline#parts#get('func').function, 'bar')
End
It can define a text part
call airline#parts#define_text('text', 'bar')
Assert Equals(airline#parts#get('text').text, 'bar')
End
It can define a raw part
call airline#parts#define_raw('raw', 'bar')
Assert Equals(airline#parts#get('raw').raw, 'bar')
End
It can define a minwidth
call airline#parts#define_minwidth('mw', 123)
Assert Equals(airline#parts#get('mw').minwidth, 123)
End
It 'can define a condition'
call airline#parts#define_condition('part', '1')
Assert Equals(airline#parts#get('part').condition, '1')
End
It 'can define a accent'
call airline#parts#define_accent('part', 'red')
Assert Equals(airline#parts#get('part').accent, 'red')
End
It 'value should be blank'
Assert Equals(airline#parts#filetype(), '')
End
It 'can overwrIte a filetype'
set ft=aaa
Assert Equals(airline#parts#filetype(), 'aaa')
End
It 'can overwrite a filetype'
"GItHub actions's vim's column is smaller than 90
set ft=aaaa
if &columns >= 90
Assert Equals(airline#parts#filetype(), 'aaaa')
else
Assert Equals(airline#parts#filetype(), 'aaa…')
endif
End
End

77
test/section.vimspec Normal file
View File

@@ -0,0 +1,77 @@
Describe section
Before
call airline#parts#define_text('text', 'text')
call airline#parts#define_raw('raw', 'raw')
call airline#parts#define_function('func', 'SectionSpec')
End
It should be able to reference default parts
let s = airline#section#create(['paste'])
Assert Equals(s, '%{airline#util#wrap(airline#parts#paste(),0)}')
End
It should create sections wIth no separators
let s = airline#section#create(['text', 'raw', 'func'])
Assert Equals(s, '%{airline#util#wrap("text",0)}raw%{airline#util#wrap(SectionSpec(),0)}')
End
It should create left sections with separators
let s = airline#section#create_left(['text', 'text'])
Assert Equals(s, '%{airline#util#wrap("text",0)}%{airline#util#append("text",0)}')
End
It should create right sections wIth separators
let s = airline#section#create_right(['text', 'text'])
Assert Equals(s, '%{airline#util#prepend("text",0)}%{airline#util#wrap("text",0)}')
End
It should prefix with accent group if provided and restore afterwards
call airline#parts#define('hi', {
\ 'raw': 'hello',
\ 'accent': 'red',
\ })
let s = airline#section#create(['hi'])
Assert Equals(s, '%#__accent_red#hello%#__restore__#')
End
It should accent functions
call airline#parts#define_function('hi', 'Hello')
call airline#parts#define_accent('hi', 'bold')
let s = airline#section#create(['hi'])
Assert Equals(s, '%#__accent_bold#%{airline#util#wrap(Hello(),0)}%#__restore__#')
End
It should parse out a section from the distro
call airline#extensions#load()
let s = airline#section#create(['whitespace'])
Assert Match(s, 'airline#extensions#whitespace#check')
End
It should use parts as is if they are not found
let s = airline#section#create(['asdf', 'func'])
Assert Equals(s, 'asdf%{airline#util#wrap(SectionSpec(),0)}')
End
It should force add separators for raw and missing keys
let s = airline#section#create_left(['asdf', 'raw'])
Assert Equals(s, 'asdf raw')
let s = airline#section#create_left(['asdf', 'aaaa', 'raw'])
Assert Equals(s, 'asdf aaaa raw')
let s = airline#section#create_right(['raw', '%f'])
Assert Equals(s, 'raw %f')
let s = airline#section#create_right(['%t', 'asdf', '%{getcwd()}'])
Assert Equals(s, '%t asdf %{getcwd()}')
End
It should empty out parts that do not pass their condition
call airline#parts#define_text('conditional', 'conditional')
call airline#parts#define_condition('conditional', '0')
let s = airline#section#create(['conditional'])
Assert Equals(s, '%{0 ? airline#util#wrap("conditional",0) : ""}')
End
It should not draw two separators after another
let s = airline#section#create_right(['ffenc','%{strftime("%H:%M")}'])
Assert Equals(s, '%{airline#util#prepend(airline#parts#ffenc(),0)}%{strftime("%H:%M")}')
End
End

91
test/themes.vimspec Normal file
View File

@@ -0,0 +1,91 @@
Describe themes.vim
After each
highlight clear Foo
highlight clear Normal
End
It should extract correct colors
call airline#highlighter#reset_hlcache()
highlight Foo ctermfg=1 ctermbg=2
let colors = airline#themes#get_highlight('Foo')
Assert Equals(colors[0], 'NONE')
Assert Equals(colors[1], 'NONE')
Assert Equals(colors[2], '1')
Assert Equals(colors[3], '2')
End
if exists("+termguicolors")
It should extract correct colors with termguicolors
call airline#highlighter#reset_hlcache()
set termguicolors
highlight Foo guifg=#cd0000 guibg=#00cd00 ctermfg=1 ctermbg=2
let colors = airline#themes#get_highlight('Foo')
Assert Equals(colors[0], '#cd0000')
Assert Equals(colors[1], '#00cd00')
Assert Equals(colors[2], '1')
Assert Equals(colors[3], '2')
End
endif
It should extract from normal if colors unavailable
call airline#highlighter#reset_hlcache()
highlight Normal ctermfg=100 ctermbg=200
highlight Foo ctermbg=2
let colors = airline#themes#get_highlight('Foo')
Assert Equals(colors[0], 'NONE')
Assert Equals(colors[1], 'NONE')
Assert Equals(colors[2], '100')
Assert Equals(colors[3], '2')
End
It should flip target group if It is reversed
call airline#highlighter#reset_hlcache()
highlight Foo ctermbg=222 ctermfg=103 cterm=reverse
let colors = airline#themes#get_highlight('Foo')
Assert Equals(colors[0], 'NONE')
Assert Equals(colors[1], 'NONE')
Assert Equals(colors[2], '222')
Assert Equals(colors[3], '103')
End
It should pass args through correctly
call airline#highlighter#reset_hlcache()
hi clear Normal
let hl = airline#themes#get_highlight('Foo', 'bold', 'italic')
Assert Equals(hl, ['NONE', 'NONE', 'NONE', 'NONE', 'bold,italic'])
let hl = airline#themes#get_highlight2(['Foo','bg'], ['Foo','fg'], 'italic', 'bold')
Assert Equals(hl, ['NONE', 'NONE', 'NONE', 'NONE', 'italic,bold'])
End
It should generate color map with mirroring
let map = airline#themes#generate_color_map(
\ [ 1, 1, 1, 1, '1' ],
\ [ 2, 2, 2, 2, '2' ],
\ [ 3, 3, 3, 3, '3' ],
\ )
Assert Equals(map.airline_a[0], 1)
Assert Equals(map.airline_b[0], 2)
Assert Equals(map.airline_c[0], 3)
Assert Equals(map.airline_x[0], 3)
Assert Equals(map.airline_y[0], 2)
Assert Equals(map.airline_z[0], 1)
End
It should generate color map with full set of colors
let map = airline#themes#generate_color_map(
\ [ 1, 1, 1, 1, '1' ],
\ [ 2, 2, 2, 2, '2' ],
\ [ 3, 3, 3, 3, '3' ],
\ [ 4, 4, 4, 4, '4' ],
\ [ 5, 5, 5, 5, '5' ],
\ [ 6, 6, 6, 6, '6' ],
\ )
Assert Equals(map.airline_a[0], 1)
Assert Equals(map.airline_b[0], 2)
Assert Equals(map.airline_c[0], 3)
Assert Equals(map.airline_x[0], 4)
Assert Equals(map.airline_y[0], 5)
Assert Equals(map.airline_z[0], 6)
End
End

69
test/util.vimspec Normal file
View File

@@ -0,0 +1,69 @@
call airline#init#bootstrap()
function! Util1()
let g:count += 1
endfunction
function! Util2()
let g:count += 2
endfunction
function! Util3(...)
let g:count = a:0
endfunction
Describe util
Before each
let g:count = 0
End
It has append wrapper function
Assert Equals(airline#util#append('', 0), '')
Assert Equals(airline#util#append('1', 0), ' 1')
End
It should be same &columns
let g:airline_statusline_ontop = 1
Assert Equals(airline#util#winwidth(), &columns)
End
It should be same winwidth(0)
let g:airline_statusline_ontop = 0
Assert Equals(airline#util#winwidth(), winwidth(0))
End
It should be same winwidth(30)
Assert Equals(airline#util#winwidth(30, 0), winwidth(30))
End
It has prepend wrapper function
Assert Equals(airline#util#prepend('', 0), '')
Assert Equals(airline#util#prepend('1', 0), '1 ')
End
It has getwinvar function
Assert Equals(airline#util#getwinvar(1, 'asdf', '123'), '123')
call setwinvar(1, 'vspec', 'is cool')
Assert Equals(airline#util#getwinvar(1, 'vspec', ''), 'is cool')
End
It has exec funcrefs helper functions
call airline#util#exec_funcrefs([function('Util1'), function('Util2')])
Assert Equals(g:count, 3)
call airline#util#exec_funcrefs([function('Util3')], 1, 2, 3, 4)
Assert Equals(g:count, 4)
End
It should ignore minwidth if less than 0
Assert Equals(airline#util#append('foo', -1), ' foo')
Assert Equals(airline#util#prepend('foo', -1), 'foo ')
Assert Equals(airline#util#wrap('foo', -1), 'foo')
End
It should return empty if winwidth() > minwidth
Assert Equals(airline#util#append('foo', 99999), '')
Assert Equals(airline#util#prepend('foo', 99999), '')
Assert Equals(airline#util#wrap('foo', 99999), '')
End
End