add tests for the builder
This commit is contained in:
parent
f5885bf9c2
commit
b4cd0ae99d
|
@ -0,0 +1,47 @@
|
||||||
|
call airline#init#bootstrap()
|
||||||
|
|
||||||
|
describe 'active builder'
|
||||||
|
before
|
||||||
|
let s:builder = airline#builder#new({'active': 1})
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should have a call to check mode'
|
||||||
|
let stl = s:builder.build()
|
||||||
|
Expect stl =~ '%{airline#check_mode()}'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should transition colors from one to the next'
|
||||||
|
call s:builder.add_section('Normal', 'hello')
|
||||||
|
call s:builder.add_section('NonText', 'world')
|
||||||
|
let stl = s:builder.build()
|
||||||
|
Expect stl =~ '%#Normal#hello%#Normal_to_NonText#>%#NonText#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('NonText', 'world')
|
||||||
|
let stl = s:builder.build()
|
||||||
|
Expect stl =~ '%#Normal#hello%#Normal_to_NonText#<%#NonText#world'
|
||||||
|
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('NonText', 'world')
|
||||||
|
let stl = s:builder.build()
|
||||||
|
Expect stl =~ '%#Normal_inactive#hello%#Normal_to_NonText_inactive#>%#NonText_inactive#world'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
30
t/init.vim
30
t/init.vim
|
@ -1,9 +1,21 @@
|
||||||
for key in ['a', 'b', 'c', 'gutter', 'x', 'y', 'z', 'warning']
|
let s:sections = ['a', 'b', 'c', 'gutter', 'x', 'y', 'z', 'warning']
|
||||||
unlet! g:airline_section_{key}
|
|
||||||
endfor
|
function! s:clear()
|
||||||
call airline#init#bootstrap()
|
for key in s:sections
|
||||||
|
unlet! g:airline_section_{key}
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|
||||||
describe 'init'
|
describe 'init'
|
||||||
|
before
|
||||||
|
call s:clear()
|
||||||
|
call airline#init#bootstrap()
|
||||||
|
end
|
||||||
|
|
||||||
|
after
|
||||||
|
call s:clear()
|
||||||
|
end
|
||||||
|
|
||||||
it 'section a should have mode, paste, iminsert'
|
it 'section a should have mode, paste, iminsert'
|
||||||
Expect g:airline_section_a =~ 'mode'
|
Expect g:airline_section_a =~ 'mode'
|
||||||
Expect g:airline_section_a =~ 'paste'
|
Expect g:airline_section_a =~ 'paste'
|
||||||
|
@ -33,5 +45,15 @@ describe 'init'
|
||||||
Expect g:airline_section_z =~ '%3l'
|
Expect g:airline_section_z =~ '%3l'
|
||||||
Expect g:airline_section_z =~ '%3c'
|
Expect g:airline_section_z =~ '%3c'
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue