From d2687440776790c2b695be97f6e1a2d0a6571030 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Fri, 30 Aug 2013 22:44:20 -0400 Subject: [PATCH] test the layout config for the default extension. --- .gitignore | 1 + autoload/airline/extensions/branch.vim | 4 +++- t/extensions_default.vim | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 t/extensions_default.vim diff --git a/.gitignore b/.gitignore index 66fb17dc..296f094e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ doc/tags *.lock +.vim-flavor diff --git a/autoload/airline/extensions/branch.vim b/autoload/airline/extensions/branch.vim index 446c89d0..0aa3da50 100644 --- a/autoload/airline/extensions/branch.vim +++ b/autoload/airline/extensions/branch.vim @@ -27,7 +27,9 @@ function! airline#extensions#branch#get_head() endif endif - return empty(head) ? s:empty_message : s:symbol.' '.head + return empty(head) + \ ? s:empty_message + \ : printf('%s%s', empty(s:symbol) ? '' : s:symbol.' ', head) endfunction function! airline#extensions#branch#init(ext) diff --git a/t/extensions_default.vim b/t/extensions_default.vim new file mode 100644 index 00000000..9eb80235 --- /dev/null +++ b/t/extensions_default.vim @@ -0,0 +1,22 @@ +call airline#init#bootstrap() + +describe 'default' + before + let s:builder = airline#builder#new({'active': 1}) + end + + it 'should use the layout' + let g:airline#extensions#default#layout = [ + \ [ 'c', 'a', 'b', 'warning' ], + \ [ 'x', 'z', 'y' ] + \ ] + call airline#extensions#default#apply(s:builder, { 'winnr': 1, 'active': 1 }) + let stl = s:builder.build() + Expect stl =~ 'airline_c_to_airline_a' + Expect stl =~ 'airline_a_to_airline_b' + Expect stl =~ 'airline_b_to_airline_warning' + Expect stl =~ 'airline_x_to_airline_z' + Expect stl =~ 'airline_z_to_airline_y' + end +end +