From 51c79f61f46be568337b5d245541a0ffbc07f39b Mon Sep 17 00:00:00 2001 From: kazukazuinaina Date: Fri, 14 May 2021 02:25:14 +0900 Subject: [PATCH] [add] winwidth's test --- autoload/airline/util.vim | 2 +- t/util.vim | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/autoload/airline/util.vim b/autoload/airline/util.vim index c090172e..337851d8 100644 --- a/autoload/airline/util.vim +++ b/autoload/airline/util.vim @@ -16,7 +16,7 @@ let s:focusgained_ignore_time = 0 " TODO: Try to cache winwidth(0) function " e.g. store winwidth per window and access that, only update it, if the size " actually changed. -function! airline#util#winwidth(...) +function! airline#util#winwidth(...) abort let nr = get(a:000, 0, 0) if get(g:, 'airline_statusline_ontop', 0) return &columns diff --git a/t/util.vim b/t/util.vim index 516938c1..dd93e5d2 100644 --- a/t/util.vim +++ b/t/util.vim @@ -20,6 +20,20 @@ describe 'util' 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 '