aboutsummaryrefslogtreecommitdiff
path: root/.vim/t/builder.vim
diff options
context:
space:
mode:
authorYaroslav <contact@yaroslavps.com>2019-09-05 19:35:38 +0300
committerYaroslav <contact@yaroslavps.com>2019-09-05 19:35:38 +0300
commit212dcd0bf753f08c0127a26a71b673c734b45c02 (patch)
tree4a43e43c7c9b9ccfcaef4088ba9e5f52154994b5 /.vim/t/builder.vim
downloadvimrice-212dcd0bf753f08c0127a26a71b673c734b45c02.tar.gz
vimrice-212dcd0bf753f08c0127a26a71b673c734b45c02.zip
init commit, extracted vim config from i3rice
Diffstat (limited to '.vim/t/builder.vim')
-rw-r--r--.vim/t/builder.vim107
1 files changed, 107 insertions, 0 deletions
diff --git a/.vim/t/builder.vim b/.vim/t/builder.vim
new file mode 100644
index 0000000..8128312
--- /dev/null
+++ b/.vim/t/builder.vim
@@ -0,0 +1,107 @@
+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