diff --git a/Gemfile b/Gemfile deleted file mode 100644 index 9f127bd4..00000000 --- a/Gemfile +++ /dev/null @@ -1,2 +0,0 @@ -source 'https://rubygems.org' -gem 'vim-flavor', '~> 4.0.1' diff --git a/Rakefile b/Rakefile deleted file mode 100644 index 741cfc25..00000000 --- a/Rakefile +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env rake - -task :default => [:test] - -task :ci => [:dump, :test] - -task :dump do - sh 'vim --version' -end - -task :test do - sh 'bundle exec vim-flavor test' -end - diff --git a/t/airline.vim b/t/airline.vim deleted file mode 100644 index 9b5af994..00000000 --- a/t/airline.vim +++ /dev/null @@ -1,86 +0,0 @@ -let g:airline_theme = 'dark' - -source plugin/airline.vim -doautocmd VimEnter - -function! MyFuncref(...) - call a:1.add_raw('hello world') - return 1 -endfunction - -function! MyIgnoreFuncref(...) - return -1 -endfunction - -function! MyAppend1(...) - call a:1.add_raw('hello') -endfunction - -function! MyAppend2(...) - call a:1.add_raw('world') -endfunction - -describe 'airline' - before - let g:airline_statusline_funcrefs = [] - end - - it 'should run user funcrefs first' - call airline#add_statusline_func('MyFuncref') - let &statusline = '' - call airline#update_statusline() - Expect airline#statusline(1) =~ 'hello world' - end - - it 'should not change the statusline with -1' - call airline#add_statusline_funcref(function('MyIgnoreFuncref')) - let &statusline = 'foo' - call airline#update_statusline() - Expect &statusline == 'foo' - end - - it 'should support multiple chained funcrefs' - call airline#add_statusline_func('MyAppend1') - call airline#add_statusline_func('MyAppend2') - call airline#update_statusline() - Expect airline#statusline(1) =~ 'helloworld' - end - - it 'should allow users to redefine sections' - let g:airline_section_a = airline#section#create(['mode', 'mode']) - call airline#update_statusline() - Expect airline#statusline(1) =~ '%{airline#util#wrap(airline#parts#mode(),0)}%#airline_a#%#airline_a_bold#%{airline#util#wrap(airline#parts#mode(),0)}%#airline_a#' - end - - it 'should remove funcrefs properly' - let c = len(g:airline_statusline_funcrefs) - call airline#add_statusline_func('MyIgnoreFuncref') - call airline#remove_statusline_func('MyIgnoreFuncref') - Expect len(g:airline_statusline_funcrefs) == c - end - - it 'should overwrite the statusline with active and inactive splits' - wincmd s - Expect airline#statusline(1) !~ 'inactive' - Expect airline#statusline(2) =~ 'inactive' - wincmd c - end - - it 'should collapse the inactive split if the variable is set true' - let g:airline_inactive_collapse = 1 - wincmd s - Expect airline#statusline(2) !~ 'airline#parts#mode' - wincmd c - end - - it 'should not collapse the inactive split if the variable is set false' - let g:airline_inactive_collapse = 0 - wincmd s - Expect airline#statusline(2) =~ 'airline#parts#mode' - wincmd c - end - - it 'should include check_mode' - Expect airline#statusline(1) =~ 'airline#check_mode' - end -end diff --git a/t/builder.vim b/t/builder.vim deleted file mode 100644 index 81283129..00000000 --- a/t/builder.vim +++ /dev/null @@ -1,107 +0,0 @@ -let g:airline_theme = 'dark' -call airline#init#bootstrap() - -describe 'active builder' - before - let s:builder = airline#builder#new({'active': 1}) - end - - it 'should start with an empty statusline' - let stl = s:builder.build() - Expect stl == '' - end - - it 'should transition colors from one to the next' - call s:builder.add_section('Normal', 'hello') - call s:builder.add_section('Search', 'world') - let stl = s:builder.build() - Expect stl =~ '%#Normal#hello%#Normal_to_Search#%#Search#world' - end - - it 'should reuse highlight group if background colors match' - call airline#highlighter#reset_hlcache() - highlight Foo1 ctermfg=1 ctermbg=2 - highlight Foo2 ctermfg=1 ctermbg=2 - call s:builder.add_section('Foo1', 'hello') - call s:builder.add_section('Foo2', 'world') - let stl = s:builder.build() - Expect stl =~ '%#Foo1#helloworld' - end - - it 'should switch highlight groups if foreground colors differ' - call airline#highlighter#reset_hlcache() - highlight Foo1 ctermfg=1 ctermbg=2 - highlight Foo2 ctermfg=2 ctermbg=2 - call s:builder.add_section('Foo1', 'hello') - call s:builder.add_section('Foo2', 'world') - let stl = s:builder.build() - Expect stl =~ '%#Foo1#hello%#Foo1_to_Foo2#%#Foo2#world' - end - - it 'should split left/right sections' - call s:builder.split() - let stl = s:builder.build() - Expect stl =~ '%=' - end - - it 'after split, sections use the right separator' - call s:builder.split() - call s:builder.add_section('Normal', 'hello') - call s:builder.add_section('Search', 'world') - let stl = s:builder.build() - Expect stl =~ 'hello%#Normal_to_Search#%#Search#world' - end - - it 'should not repeat the same highlight group' - call s:builder.add_section('Normal', 'hello') - call s:builder.add_section('Normal', 'hello') - let stl = s:builder.build() - Expect stl == '%#Normal#hellohello' - end - - it 'should replace accent groups with the specified group' - call s:builder.add_section('Normal', '%#__accent_foo#hello') - let stl = s:builder.build() - Expect stl == '%#Normal#%#Normal_foo#hello' - end - - it 'should replace two accent groups with correct groups' - call s:builder.add_section('Normal', '%#__accent_foo#hello%#__accent_bar#world') - let stl = s:builder.build() - Expect stl =~ '%#Normal_foo#hello%#Normal_bar#world' - end - - it 'should special restore group should go back to previous group' - call s:builder.add_section('Normal', '%#__restore__#') - let stl = s:builder.build() - Expect stl !~ '%#__restore__#' - Expect stl =~ '%#Normal#' - end - - it 'should blend colors from the left through the split to the right' - call s:builder.add_section('Normal', 'hello') - call s:builder.split() - call s:builder.add_section('Search', 'world') - let stl = s:builder.build() - Expect stl =~ 'Normal_to_Search' - end -end - -describe 'inactive builder' - before - let s:builder = airline#builder#new({'active': 0}) - end - - it 'should transition colors from one to the next' - call s:builder.add_section('Normal', 'hello') - call s:builder.add_section('Search', 'world') - let stl = s:builder.build() - Expect stl =~ '%#Normal_inactive#hello%#Normal_to_Search_inactive#%#Search_inactive#world' - end - - it 'should not render accents' - call s:builder.add_section('Normal', '%#__accent_foo#hello%#foo#foo%#__accent_bar#world') - let stl = s:builder.build() - Expect stl == '%#Normal_inactive#hello%#foo_inactive#fooworld' - end -end diff --git a/t/commands.vim b/t/commands.vim deleted file mode 100644 index fe3ad2cc..00000000 --- a/t/commands.vim +++ /dev/null @@ -1,52 +0,0 @@ -source plugin/airline.vim -doautocmd VimEnter - -describe 'commands' - it 'should toggle off and on' - execute 'AirlineToggle' - Expect exists('#airline') to_be_false - execute 'AirlineToggle' - Expect exists('#airline') to_be_true - end - - it 'should toggle whitespace off' - call airline#extensions#load() - execute 'AirlineToggleWhitespace' - Expect exists('#airline_whitespace') to_be_false - end - - it 'should toggle whitespace on' - call airline#extensions#load() - execute 'AirlineToggleWhitespace' - Expect exists('#airline_whitespace') to_be_true - end - - it 'should display theme name "simple"' - execute 'AirlineTheme simple' - Expect g:airline_theme == 'simple' - end - - it 'should display theme name "dark"' - execute 'AirlineTheme dark' - Expect g:airline_theme == 'dark' - end - - it 'should display theme name "dark" because specifying a name that does not exist' - execute 'AirlineTheme doesnotexist' - Expect g:airline_theme == 'dark' - end - - it 'should display theme name molokai' - colors molokai - Expect g:airline_theme == 'molokai' - end - - it 'should have a refresh command' - Expect exists(':AirlineRefresh') to_be_true - end - - it 'should have a extensions command' - Expect exists(':AirlineExtensions') to_be_true - end - -end diff --git a/t/extensions_default.vim b/t/extensions_default.vim deleted file mode 100644 index f2b07bce..00000000 --- a/t/extensions_default.vim +++ /dev/null @@ -1,50 +0,0 @@ -let g:airline#extensions#default#layout = [ - \ [ 'c', 'a', 'b', 'warning' ], - \ [ 'x', 'z', 'y' ] - \ ] - -source plugin/airline.vim -doautocmd VimEnter - -describe 'default' - before - let s:builder = airline#builder#new({'active': 1}) - end - - it 'should use the layout "airline_a_to_airline_b"' - call airline#extensions#default#apply(s:builder, { 'winnr': 1, 'active': 1 }) - let stl = s:builder.build() - Expect stl =~ 'airline_c_to_airline_a' - end - - it 'should use the layout "airline_a_to_airline_b"' - call airline#extensions#default#apply(s:builder, { 'winnr': 1, 'active': 1 }) - let stl = s:builder.build() - Expect stl =~ 'airline_a_to_airline_b' - end - - it 'should use the layout "airline_b_to_airline_warning"' - call airline#extensions#default#apply(s:builder, { 'winnr': 1, 'active': 1 }) - let stl = s:builder.build() - Expect stl =~ 'airline_b_to_airline_warning' - end - - it 'should use the layout "airline_x_to_airline_z"' - call airline#extensions#default#apply(s:builder, { 'winnr': 1, 'active': 1 }) - let stl = s:builder.build() - Expect stl =~ 'airline_x_to_airline_z' - end - - it 'should use the layout "airline_z_to_airline_y"' - call airline#extensions#default#apply(s:builder, { 'winnr': 1, 'active': 1 }) - let stl = s:builder.build() - Expect stl =~ 'airline_z_to_airline_y' - end - - it 'should only render warning section in active splits' - wincmd s - Expect airline#statusline(1) =~ 'warning' - Expect airline#statusline(2) !~ 'warning' - wincmd c - end -end diff --git a/t/extensions_tabline.vim b/t/extensions_tabline.vim deleted file mode 100644 index 31f0c8d8..00000000 --- a/t/extensions_tabline.vim +++ /dev/null @@ -1,21 +0,0 @@ -let g:airline#extensions#tabline#enabled = 1 - -source plugin/airline.vim -doautocmd VimEnter - -describe 'default' - - it 'should use a tabline' - e! CHANGELOG.md - sp CONTRIBUTING.md - Expect airline#extensions#tabline#get() =~# '%#airline_tab# %(%{airline#extensions#tabline#get_buffer_name(\d)}%) %#airline_tab_to_airline_tabsel# %#airline_tabsel#%(%{airline#extensions#tabline#get_buffer_name(\d)}%) %#airline_tabsel_to_airline_tabfill# %#airline_tabfill#%=%#airline_tabfill_to_airline_tabfill#%#airline_tabfill#%#airline_tabfill_to_airline_tablabel_right#%#airline_tablabel_right# buffers ' - end - - it 'Trigger on BufDelete autocommands' - e! CHANGELOG.md - sp CONTRIBUTING.md - sp README.md - 2bd - Expect airline#extensions#tabline#get() =~# '%#airline_tab# %(%{airline#extensions#tabline#get_buffer_name(\d)}%) | %(%{airline#extensions#tabline#get_buffer_name(\d)}%) %#airline_tab_to_airline_tabsel# %#airline_tabsel#%(%{airline#extensions#tabline#get_buffer_name(\d)}%) %#airline_tabsel_to_airline_tabfill# %#airline_tabfill#%=%#airline_tabfill_to_airline_tabfill#%#airline_tabfill#%#airline_tabfill_to_airline_tablabel_right#%#airline_tablabel_right# buffers ' - end -end diff --git a/t/highlighter.vim b/t/highlighter.vim deleted file mode 100644 index 36356e8d..00000000 --- a/t/highlighter.vim +++ /dev/null @@ -1,31 +0,0 @@ -let g:airline_theme = 'dark' - -describe 'highlighter' - it 'should create separator highlight groups' - hi Foo1 ctermfg=1 ctermbg=2 - hi Foo2 ctermfg=3 ctermbg=4 - call airline#highlighter#add_separator('Foo1', 'Foo2', 0) - let hl = airline#highlighter#get_highlight('Foo1_to_Foo2') - Expect hl == [ 'NONE', 'NONE', '4', '2', '' ] - end - - if exists("+termguicolors") - it 'should create separator highlight groups with termguicolors' - set termguicolors - hi Foo1 guifg=#cd0000 guibg=#00cd00 ctermfg=1 ctermbg=2 - hi Foo2 guifg=#cdcd00 guibg=#0000ee ctermfg=3 ctermbg=4 - call airline#highlighter#add_separator('Foo1', 'Foo2', 0) - let hl = airline#highlighter#get_highlight('Foo1_to_Foo2') - Expect hl == [ '#0000ee', '#00cd00', '4', '2', '' ] - end - endif - - it 'should populate accent colors' - Expect exists('g:airline#themes#dark#palette.normal.airline_c_red') to_be_false - Expect hlID('airline_c_red') == 0 - call airline#themes#patch(g:airline#themes#dark#palette) - call airline#highlighter#add_accent('red') - call airline#highlighter#highlight(['normal']) - Expect hlID('airline_c_red') != 0 - end -end diff --git a/t/init.vim b/t/init.vim deleted file mode 100644 index f6b8734a..00000000 --- a/t/init.vim +++ /dev/null @@ -1,114 +0,0 @@ -let s:sections = ['a', 'b', 'c', 'gutter', 'x', 'y', 'z', 'warning'] - -function! s:clear() - for key in s:sections - unlet! g:airline_section_{key} - endfor -endfunction - -call airline#init#bootstrap() - -describe 'init sections' - before - call s:clear() - call airline#init#sections() - end - - after - call s:clear() - end - - it 'section a should have mode, paste, spell, iminsert' - Expect g:airline_section_a =~ 'mode' - Expect g:airline_section_a =~ 'paste' - Expect g:airline_section_a =~ 'spell' - Expect g:airline_section_a =~ 'iminsert' - end - - it 'section b should be blank because no extensions are installed' - Expect g:airline_section_b == '' - end - - it 'section c should be file and coc_status' - Expect 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() - Expect 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' - Expect 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' - Expect g:airline_section_y =~ 'ff' - Expect g:airline_section_y =~ 'fenc' - end - - it 'section z should be line numbers' - Expect g:airline_section_z =~ '%p%%' - Expect g:airline_section_z =~ '%l' - Expect 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 - Expect g:airline_section_gutter =~ '%=' - end - - it 'section warning should be blank' - Expect 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 - Expect g:airline_section_{s} == s - endfor - end - - it 'all default statusline extensions should be blank' - Expect airline#parts#get('ale_error_count').raw == '' - Expect airline#parts#get('ale_warning_count').raw == '' - Expect airline#parts#get('lsp_error_count').raw == '' - Expect airline#parts#get('lsp_warning_count').raw == '' - Expect airline#parts#get('nvimlsp_error_count').raw == '' - Expect airline#parts#get('nvimlsp_warning_count').raw == '' - Expect airline#parts#get('hunks').raw == '' - Expect airline#parts#get('branch').raw == '' - Expect airline#parts#get('eclim').raw == '' - Expect airline#parts#get('neomake_error_count').raw == '' - Expect airline#parts#get('neomake_warning_count').raw == '' - Expect airline#parts#get('obsession').raw == '' - Expect airline#parts#get('syntastic-err').raw == '' - Expect airline#parts#get('syntastic-warn').raw == '' - Expect airline#parts#get('tagbar').raw == '' - Expect airline#parts#get('whitespace').raw == '' - Expect airline#parts#get('windowswap').raw == '' - Expect airline#parts#get('ycm_error_count').raw == '' - Expect airline#parts#get('ycm_warning_count').raw == '' - Expect airline#parts#get('languageclient_error_count').raw == '' - Expect airline#parts#get('languageclient_warning_count').raw == '' - Expect airline#parts#get('coc_status').raw == '' - Expect airline#parts#get('coc_current_function').raw == '' - Expect airline#parts#get('vista').raw == '' - Expect airline#parts#get('coc_warning_count').raw == '' - Expect airline#parts#get('coc_error_count').raw == '' - Expect airline#parts#get('battery').raw == '' - end -end - -describe 'init parts' - it 'should not redefine parts already defined' - call airline#parts#define_raw('linenr', 'bar') - call airline#init#sections() - Expect g:airline_section_z =~ 'bar' - end -end diff --git a/t/parts.vim b/t/parts.vim deleted file mode 100644 index 32dd94af..00000000 --- a/t/parts.vim +++ /dev/null @@ -1,58 +0,0 @@ -describe 'parts' - it 'overwrites existing values' - call airline#parts#define('foo', { 'test': '123' }) - Expect airline#parts#get('foo').test == '123' - call airline#parts#define('foo', { 'test': '321' }) - Expect airline#parts#get('foo').test == '321' - end - - it 'can define a function part' - call airline#parts#define_function('func', 'bar') - Expect airline#parts#get('func').function == 'bar' - end - - it 'can define a text part' - call airline#parts#define_text('text', 'bar') - Expect airline#parts#get('text').text == 'bar' - end - - it 'can define a raw part' - call airline#parts#define_raw('raw', 'bar') - Expect airline#parts#get('raw').raw == 'bar' - end - - it 'can define a minwidth' - call airline#parts#define_minwidth('mw', 123) - Expect airline#parts#get('mw').minwidth == 123 - end - - it 'can define a condition' - call airline#parts#define_condition('part', '1') - Expect airline#parts#get('part').condition == '1' - end - - it 'can define a accent' - call airline#parts#define_accent('part', 'red') - Expect airline#parts#get('part').accent == 'red' - end - - it 'value should be blank' - Expect airline#parts#filetype() == '' - end - - it 'can overwrite a filetype' - set ft=aaa - Expect 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 - Expect airline#parts#filetype() == 'aaaa' - else - Expect airline#parts#filetype() == 'aaa…' - endif - end - -end diff --git a/t/section.vim b/t/section.vim deleted file mode 100644 index 50717a7d..00000000 --- a/t/section.vim +++ /dev/null @@ -1,80 +0,0 @@ -function! SectionSpec() -endfunction - -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']) - Expect s == '%{airline#util#wrap(airline#parts#paste(),0)}' - end - - it 'should create sections with no separators' - let s = airline#section#create(['text', 'raw', 'func']) - Expect 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']) - Expect 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']) - Expect 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']) - Expect 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']) - Expect 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']) - Expect s =~ 'airline#extensions#whitespace#check' - end - - it 'should use parts as is if they are not found' - let s = airline#section#create(['asdf', 'func']) - Expect 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']) - Expect s == 'asdf raw' - let s = airline#section#create_left(['asdf', 'aaaa', 'raw']) - Expect s == 'asdf aaaa raw' - let s = airline#section#create_right(['raw', '%f']) - Expect s == 'raw %f' - let s = airline#section#create_right(['%t', 'asdf', '%{getcwd()}']) - Expect 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']) - Expect 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")}']) - Expect s == '%{airline#util#prepend(airline#parts#ffenc(),0)}%{strftime("%H:%M")}' - end -end diff --git a/t/themes.vim b/t/themes.vim deleted file mode 100644 index 6e50d08f..00000000 --- a/t/themes.vim +++ /dev/null @@ -1,91 +0,0 @@ -describe 'themes' - after - 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') - Expect colors[0] == 'NONE' - Expect colors[1] == 'NONE' - Expect colors[2] == '1' - Expect 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') - Expect colors[0] == '#cd0000' - Expect colors[1] == '#00cd00' - Expect colors[2] == '1' - Expect 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') - Expect colors[0] == 'NONE' - Expect colors[1] == 'NONE' - Expect colors[2] == '100' - Expect 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') - Expect colors[0] == 'NONE' - Expect colors[1] == 'NONE' - Expect colors[2] == '222' - Expect 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') - Expect hl == ['NONE', 'NONE', 'NONE', 'NONE', 'bold,italic'] - - let hl = airline#themes#get_highlight2(['Foo','bg'], ['Foo','fg'], 'italic', 'bold') - Expect 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' ], - \ ) - Expect map.airline_a[0] == 1 - Expect map.airline_b[0] == 2 - Expect map.airline_c[0] == 3 - Expect map.airline_x[0] == 3 - Expect map.airline_y[0] == 2 - Expect 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' ], - \ ) - Expect map.airline_a[0] == 1 - Expect map.airline_b[0] == 2 - Expect map.airline_c[0] == 3 - Expect map.airline_x[0] == 4 - Expect map.airline_y[0] == 5 - Expect map.airline_z[0] == 6 - end -end diff --git a/t/util.vim b/t/util.vim deleted file mode 100644 index dd93e5d2..00000000 --- a/t/util.vim +++ /dev/null @@ -1,67 +0,0 @@ -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 - let g:count = 0 - end - - it 'has append wrapper function' - Expect airline#util#append('', 0) == '' - Expect airline#util#append('1', 0) == ' 1' - end - - it 'should be same &columns' - let g:airline_statusline_ontop = 1 - Expect airline#util#winwidth() == &columns - end - - it 'should be same winwidth(0)' - let g:airline_statusline_ontop = 0 - Expect airline#util#winwidth() == winwidth(0) - end - - it 'should be same winwidth(30)' - Expect airline#util#winwidth(30, 0) == winwidth(30) - end - - it 'has prepend wrapper function' - Expect airline#util#prepend('', 0) == '' - Expect airline#util#prepend('1', 0) == '1 ' - end - - it 'has getwinvar function' - Expect airline#util#getwinvar(1, 'asdf', '123') == '123' - call setwinvar(1, 'vspec', 'is cool') - Expect airline#util#getwinvar(1, 'vspec', '') == 'is cool' - end - - it 'has exec funcrefs helper functions' - call airline#util#exec_funcrefs([function('Util1'), function('Util2')]) - Expect g:count == 3 - - call airline#util#exec_funcrefs([function('Util3')], 1, 2, 3, 4) - Expect g:count == 4 - end - - it 'should ignore minwidth if less than 0' - Expect airline#util#append('foo', -1) == ' foo' - Expect airline#util#prepend('foo', -1) == 'foo ' - Expect airline#util#wrap('foo', -1) == 'foo' - end - - it 'should return empty if winwidth() > minwidth' - Expect airline#util#append('foo', 99999) == '' - Expect airline#util#prepend('foo', 99999) == '' - Expect airline#util#wrap('foo', 99999) == '' - end -end diff --git a/test/extensions_tabline.vimspec b/test/extensions_tabline.vimspec index 969f1be6..36a6bc4b 100644 --- a/test/extensions_tabline.vimspec +++ b/test/extensions_tabline.vimspec @@ -1,7 +1,4 @@ Describe extensions_tabline.vim - Before all - :%bd - End It should use a tabline e! file1 diff --git a/test/init.vimspec b/test/init.vimspec new file mode 100644 index 00000000..4b111d67 --- /dev/null +++ b/test/init.vimspec @@ -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 diff --git a/test/parts.vimspec b/test/parts.vimspec new file mode 100644 index 00000000..01a774c8 --- /dev/null +++ b/test/parts.vimspec @@ -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 diff --git a/test/section.vimspec b/test/section.vimspec new file mode 100644 index 00000000..0a9fd6ed --- /dev/null +++ b/test/section.vimspec @@ -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 diff --git a/test/themes.vimspec b/test/themes.vimspec new file mode 100644 index 00000000..2a3cfab8 --- /dev/null +++ b/test/themes.vimspec @@ -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 diff --git a/test/util.vimspec b/test/util.vimspec new file mode 100644 index 00000000..56679c33 --- /dev/null +++ b/test/util.vimspec @@ -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