mirror of
https://github.com/vim-airline/vim-airline.git
synced 2024-11-26 18:31:02 +08:00
Merge pull request #2490 from vim-airline/replace-testing-framework
replace testing flamework, Using vim-themis
This commit is contained in:
commit
83d853adc7
48
.github/workflows/ci.yml
vendored
48
.github/workflows/ci.yml
vendored
|
@ -3,10 +3,10 @@ name: CI
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
|
@ -14,38 +14,30 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
vim_version:
|
vim:
|
||||||
- 'v8.2.2000'
|
- v8.2.1000
|
||||||
- 'v8.2.1000'
|
- v8.2.0000
|
||||||
- 'v8.2.0000'
|
- v8.1.0000
|
||||||
- 'v8.1.0000'
|
- v8.0.0000
|
||||||
- 'v8.0.0000'
|
- v7.4
|
||||||
- 'v7.4'
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup Ruby
|
- name: Checkout vim-themis
|
||||||
uses: ruby/setup-ruby@v1
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
ruby-version: '3.0'
|
repository: thinca/vim-themis
|
||||||
|
path: vim-themis
|
||||||
- name: Setup Bundle
|
|
||||||
run: |
|
|
||||||
gem install bundler
|
|
||||||
bundle install --jobs 4 --retry 3
|
|
||||||
|
|
||||||
- name: Setup Vim
|
- name: Setup Vim
|
||||||
uses: thinca/action-setup-vim@v1
|
uses: rhysd/action-setup-vim@v1
|
||||||
|
id: vim
|
||||||
with:
|
with:
|
||||||
vim_version: ${{ matrix.vim_version }}
|
version: ${{ matrix.vim }}
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Test
|
||||||
run: |
|
env:
|
||||||
curl -f -L "https://raw.githubusercontent.com/vim-airline/vim-airline-themes/master/autoload/airline/themes/simple.vim" -o autoload/airline/themes/simple.vim
|
THEMIS_VIM: ${{ steps.vim.outputs.executable }}
|
||||||
curl -f -L "https://raw.githubusercontent.com/vim-airline/vim-airline-themes/master/autoload/airline/themes/molokai.vim" -o autoload/airline/themes/molokai.vim
|
run: ./vim-themis/bin/themis --reporter spec
|
||||||
mkdir colors && curl -f -L 'https://raw.githubusercontent.com/tomasr/molokai/master/colors/molokai.vim' -o colors/molokai.vim
|
|
||||||
|
|
||||||
- name: Run Test
|
|
||||||
run: rake ci
|
|
||||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -5,4 +5,4 @@ doc/tags
|
||||||
*.swp
|
*.swp
|
||||||
.bundle
|
.bundle
|
||||||
vendor
|
vendor
|
||||||
|
test/.deps
|
||||||
|
|
|
@ -6,6 +6,23 @@ Contributions and pull requests are welcome. Please take note of the following
|
||||||
* Keep the history clean! Squash your branches before you submit a pull request. `pull --rebase` is your friend.
|
* Keep the history clean! Squash your branches before you submit a pull request. `pull --rebase` is your friend.
|
||||||
* Any changes to the core should be tested against Vim 7.4.
|
* Any changes to the core should be tested against Vim 7.4.
|
||||||
|
|
||||||
|
# Testing
|
||||||
|
|
||||||
|
Contributers should install [thinca/vim-themis](https://github.com/thinca/vim-themis) to run tests before sending a PR if they applied some modification to the code. PRs which does not pass tests won't be accepted.
|
||||||
|
|
||||||
|
## 1. Installation
|
||||||
|
|
||||||
|
```
|
||||||
|
$ cd /path/to/vim-airline
|
||||||
|
$ git submodule add https://github.com/thinca/vim-themis ./.themis-bin
|
||||||
|
```
|
||||||
|
|
||||||
|
## 2. running test
|
||||||
|
|
||||||
|
```
|
||||||
|
$ ./path/to/themis-bin/bin/themis path/to/vim-airline/test --reporter spec
|
||||||
|
```
|
||||||
|
|
||||||
# Bugs
|
# Bugs
|
||||||
|
|
||||||
Tracking down bugs can take a very long time due to different configurations, versions, and operating systems. To ensure a timely response, please help me out by doing the following:
|
Tracking down bugs can take a very long time due to different configurations, versions, and operating systems. To ensure a timely response, please help me out by doing the following:
|
||||||
|
|
14
Rakefile
14
Rakefile
|
@ -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
|
|
||||||
|
|
|
@ -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
|
|
107
t/builder.vim
107
t/builder.vim
|
@ -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
|
|
|
@ -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
|
|
|
@ -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
|
|
|
@ -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
|
|
|
@ -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
|
|
114
t/init.vim
114
t/init.vim
|
@ -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
|
|
58
t/parts.vim
58
t/parts.vim
|
@ -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
|
|
|
@ -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
|
|
91
t/themes.vim
91
t/themes.vim
|
@ -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
|
|
67
t/util.vim
67
t/util.vim
|
@ -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
|
|
28
test/.themisrc
Normal file
28
test/.themisrc
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
let s:helper = themis#helper('assert')
|
||||||
|
let s:deps = themis#helper('deps')
|
||||||
|
|
||||||
|
call themis#helper('command').with(s:helper)
|
||||||
|
call s:deps.git('vim-airline/vim-airline-themes')
|
||||||
|
call s:deps.git('tomasr/molokai')
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
let g:airline#extensions#default#layout = [
|
||||||
|
\ [ 'c', 'a', 'b', 'warning' ],
|
||||||
|
\ [ 'x', 'z', 'y' ]
|
||||||
|
\ ]
|
64
test/airline.vimspec
Normal file
64
test/airline.vimspec
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
Describe airline.vim
|
||||||
|
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()
|
||||||
|
Assert Match(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()
|
||||||
|
Assert Equals(&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()
|
||||||
|
Assert Match(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()
|
||||||
|
Assert Match(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')
|
||||||
|
Assert Equals(len(g:airline_statusline_funcrefs), c)
|
||||||
|
End
|
||||||
|
|
||||||
|
It should overwrite the statusline with active and inactive splits
|
||||||
|
wincmd s
|
||||||
|
Assert NotMatch(airline#statusline(1), 'inactive')
|
||||||
|
Assert Match(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
|
||||||
|
Assert NotMatch(getwinvar(2, '&statusline'), 'airline#parts#mode')
|
||||||
|
wincmd c
|
||||||
|
end
|
||||||
|
|
||||||
|
It should collapse the inactive split if the variable is set false
|
||||||
|
let g:airline_inactive_collapse = 0
|
||||||
|
wincmd s
|
||||||
|
Assert NotEquals(getwinvar(2, '&statusline'), 'airline#parts#mode')
|
||||||
|
wincmd c
|
||||||
|
End
|
||||||
|
|
||||||
|
It should include check_mode
|
||||||
|
Assert Match(airline#statusline(1), 'airline#check_mode')
|
||||||
|
End
|
||||||
|
End
|
107
test/builder.vimspec
Normal file
107
test/builder.vimspec
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
Describe builder.vim
|
||||||
|
Describe active builder
|
||||||
|
Before each
|
||||||
|
let s:builder = airline#builder#new({'active': 1})
|
||||||
|
End
|
||||||
|
|
||||||
|
It should start with an empty statusline
|
||||||
|
let stl = s:builder.build()
|
||||||
|
Assert Equals(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()
|
||||||
|
Assert Match(stl,'%#Normal#hello%#Normal_to_Search#%#Search#world')
|
||||||
|
End
|
||||||
|
|
||||||
|
|
||||||
|
It should reuse highlight group if background colors match
|
||||||
|
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()
|
||||||
|
Assert Match(stl, '%#Foo1#helloworld')
|
||||||
|
End
|
||||||
|
|
||||||
|
|
||||||
|
It should switch highlight groups if foreground colors differ
|
||||||
|
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()
|
||||||
|
Assert Match(stl, '%#Foo1#hello%#Foo1_to_Foo2#%#Foo2#world')
|
||||||
|
End
|
||||||
|
|
||||||
|
It should split left/right sections
|
||||||
|
call s:builder.split()
|
||||||
|
let stl = s:builder.build()
|
||||||
|
Assert Match(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()
|
||||||
|
Assert Match(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()
|
||||||
|
Assert Match(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()
|
||||||
|
Assert Match(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()
|
||||||
|
Assert Match(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()
|
||||||
|
Assert NotMatch(stl, '%#__restore__#')
|
||||||
|
Assert Match(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()
|
||||||
|
Assert Match(stl, 'Normal_to_Search')
|
||||||
|
End
|
||||||
|
End
|
||||||
|
|
||||||
|
Describe inactive builder
|
||||||
|
Before each
|
||||||
|
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()
|
||||||
|
Assert Match(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()
|
||||||
|
Assert Equals(stl, '%#Normal_inactive#hello%#foo_inactive#fooworld')
|
||||||
|
End
|
||||||
|
End
|
||||||
|
|
||||||
|
End
|
50
test/commands.vimspec
Normal file
50
test/commands.vimspec
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
Describe commands.vim
|
||||||
|
|
||||||
|
It should toggle off and on
|
||||||
|
execute 'AirlineToggle'
|
||||||
|
Assert False(exists('#airline'))
|
||||||
|
execute 'AirlineToggle'
|
||||||
|
Assert True(exists('#airline'))
|
||||||
|
End
|
||||||
|
|
||||||
|
It should toggle whitespace off
|
||||||
|
call airline#extensions#load()
|
||||||
|
execute 'AirlineToggleWhitespace'
|
||||||
|
Assert False(exists('#airline_whitespace'))
|
||||||
|
End
|
||||||
|
|
||||||
|
It should toggle whitespace on
|
||||||
|
call airline#extensions#load()
|
||||||
|
execute 'AirlineToggleWhitespace'
|
||||||
|
Assert True(exists('#airline_whitespace'))
|
||||||
|
End
|
||||||
|
|
||||||
|
It should display theme name "simple"
|
||||||
|
execute 'AirlineTheme simple'
|
||||||
|
Assert Equals(g:airline_theme, 'simple')
|
||||||
|
End
|
||||||
|
|
||||||
|
It should display theme name "dark"'
|
||||||
|
execute 'AirlineTheme dark'
|
||||||
|
Assert Equals(g:airline_theme, 'dark')
|
||||||
|
End
|
||||||
|
|
||||||
|
It should display theme name "dark" because specifying a name that does not exist
|
||||||
|
execute 'AirlineTheme doesnotexist'
|
||||||
|
Assert Equals(g:airline_theme, 'dark')
|
||||||
|
End
|
||||||
|
|
||||||
|
It should display theme name molokai
|
||||||
|
colors molokai
|
||||||
|
Assert Equals(g:airline_theme, 'molokai')
|
||||||
|
End
|
||||||
|
|
||||||
|
It should have a refresh command
|
||||||
|
Assert Equals(exists(':AirlineRefresh'), 2)
|
||||||
|
End
|
||||||
|
|
||||||
|
It should have a extensions command
|
||||||
|
Assert Equals(exists(':AirlineExtensions'), 2)
|
||||||
|
End
|
||||||
|
|
||||||
|
End
|
47
test/extensions_default.vimspec
Normal file
47
test/extensions_default.vimspec
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
Describe extensions_default.vim
|
||||||
|
Before
|
||||||
|
let g:airline#extensions#default#layout = [
|
||||||
|
\ [ 'c', 'a', 'b', 'warning' ],
|
||||||
|
\ [ 'x', 'z', 'y' ]
|
||||||
|
\ ]
|
||||||
|
|
||||||
|
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()
|
||||||
|
Assert Match(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()
|
||||||
|
Assert Match(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()
|
||||||
|
Assert Match(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()
|
||||||
|
Assert Match(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()
|
||||||
|
Assert Match(stl, 'airline_z_to_airline_y')
|
||||||
|
end
|
||||||
|
|
||||||
|
it should only render warning section in active splits
|
||||||
|
wincmd s
|
||||||
|
Assert Match(airline#statusline(1), 'warning')
|
||||||
|
Assert NotMatch(airline#statusline(2), 'warning')
|
||||||
|
wincmd c
|
||||||
|
end
|
||||||
|
end
|
14
test/extensions_tabline.vimspec
Normal file
14
test/extensions_tabline.vimspec
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
Describe extensions_tabline.vim
|
||||||
|
|
||||||
|
It should use a tabline
|
||||||
|
e! file1
|
||||||
|
Assert Match(airline#extensions#tabline#get(), '%#airline_tabsel# %(%{airline#extensions#tabline#get_buffer_name(\d)}%) |%=%#airline_tabfill_to_airline_tabfill#%#airline_tabfill# buffers' )
|
||||||
|
End
|
||||||
|
|
||||||
|
It Trigger on BufDelete autocommands
|
||||||
|
e! file1
|
||||||
|
sp file2
|
||||||
|
bd
|
||||||
|
Assert Match(airline#extensions#tabline#get(), '%#airline_tabsel# %(%{airline#extensions#tabline#get_buffer_name(\d)}%) |%=%#airline_tabfill_to_airline_tabfill#%#airline_tabfill# buffers' )
|
||||||
|
End
|
||||||
|
End
|
28
test/highlighter.vimspec
Normal file
28
test/highlighter.vimspec
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
Describe highlighter.vim
|
||||||
|
It should create separator highlight groups
|
||||||
|
hi highlighter1 ctermfg=1 ctermbg=2
|
||||||
|
hi highlighter2 ctermfg=3 ctermbg=4
|
||||||
|
call airline#highlighter#add_separator('highlighter1', 'highlighter2', 0)
|
||||||
|
let hl = airline#highlighter#get_highlight('highlighter1_to_highlighter2')
|
||||||
|
Assert Equal([ 'NONE', 'NONE', '4', '2', '' ], hl)
|
||||||
|
End
|
||||||
|
|
||||||
|
if exists("+termguicolors")
|
||||||
|
It should create separator highlight groups with termguicolors
|
||||||
|
set termguicolors
|
||||||
|
hi highlighter1 guifg=#cd0000 guibg=#00cd00 ctermfg=1 ctermbg=2
|
||||||
|
hi highlighter2 guifg=#cdcd00 guibg=#0000ee ctermfg=3 ctermbg=4
|
||||||
|
call airline#highlighter#add_separator('highlighter1', 'highlighter2', 0)
|
||||||
|
let hl = airline#highlighter#get_highlight('highlighter1_to_highlighter2')
|
||||||
|
Assert Equal(['#0000ee', '#00cd00', '4', '2', '' ], hl)
|
||||||
|
End
|
||||||
|
endif
|
||||||
|
|
||||||
|
It should populate accent colors
|
||||||
|
Assert False(exists('g:airline#themes#dark#palette.normal.airline_c_red'))
|
||||||
|
call airline#themes#patch(g:airline#themes#dark#palette)
|
||||||
|
call airline#highlighter#add_accent('red')
|
||||||
|
call airline#highlighter#highlight(['normal'])
|
||||||
|
Assert NotEqual(0, hlID('airline_c_red'))
|
||||||
|
End
|
||||||
|
End
|
109
test/init.vimspec
Normal file
109
test/init.vimspec
Normal 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
58
test/parts.vimspec
Normal 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
77
test/section.vimspec
Normal 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
91
test/themes.vimspec
Normal 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
69
test/util.vimspec
Normal 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
|
Loading…
Reference in New Issue
Block a user