2013-09-18 04:45:12 +02:00
|
|
|
let g:airline_theme = 'dark'
|
2013-08-31 03:28:38 +02:00
|
|
|
call airline#init#bootstrap()
|
|
|
|
|
|
|
|
describe 'active builder'
|
|
|
|
before
|
|
|
|
let s:builder = airline#builder#new({'active': 1})
|
|
|
|
end
|
|
|
|
|
2013-09-02 20:55:15 +02:00
|
|
|
it 'should start with an empty statusline'
|
2013-08-31 03:28:38 +02:00
|
|
|
let stl = s:builder.build()
|
2013-09-02 20:55:15 +02:00
|
|
|
Expect stl == ''
|
2013-08-31 03:28:38 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should transition colors from one to the next'
|
|
|
|
call s:builder.add_section('Normal', 'hello')
|
2014-10-18 19:59:24 +02:00
|
|
|
call s:builder.add_section('Search', 'world')
|
2013-08-31 03:28:38 +02:00
|
|
|
let stl = s:builder.build()
|
2014-10-18 19:59:24 +02:00
|
|
|
Expect stl =~ '%#Normal#hello%#Normal_to_Search#>%#Search#world'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should reuse highlight group if background colors match'
|
|
|
|
highlight Foo1 ctermfg=1 ctermbg=2
|
2014-11-15 20:49:02 +01:00
|
|
|
highlight Foo2 ctermfg=1 ctermbg=2
|
2014-10-18 19:59:24 +02:00
|
|
|
call s:builder.add_section('Foo1', 'hello')
|
|
|
|
call s:builder.add_section('Foo2', 'world')
|
|
|
|
let stl = s:builder.build()
|
|
|
|
Expect stl =~ '%#Foo1#hello>world'
|
2013-08-31 03:28:38 +02:00
|
|
|
end
|
|
|
|
|
2014-11-15 20:49:02 +01:00
|
|
|
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()
|
|
|
|
Expect stl =~ '%#Foo1#hello%#Foo1_to_Foo2#>%#Foo2#world'
|
|
|
|
end
|
|
|
|
|
2013-08-31 03:28:38 +02:00
|
|
|
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')
|
2014-10-18 19:59:24 +02:00
|
|
|
call s:builder.add_section('Search', 'world')
|
2013-08-31 03:28:38 +02:00
|
|
|
let stl = s:builder.build()
|
2014-10-18 19:59:24 +02:00
|
|
|
Expect stl =~ 'hello%#Normal_to_Search#<%#Search#world'
|
2013-08-31 03:28:38 +02:00
|
|
|
end
|
2013-09-07 05:06:08 +02:00
|
|
|
|
|
|
|
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#hello>hello'
|
|
|
|
end
|
2013-09-16 04:47:13 +02:00
|
|
|
|
|
|
|
it 'should replace accent groups with the specified group'
|
2013-09-22 21:20:06 +02:00
|
|
|
call s:builder.add_section('Normal', '%#__accent_foo#hello')
|
2013-09-16 04:47:13 +02:00
|
|
|
let stl = s:builder.build()
|
|
|
|
Expect stl == '%#Normal#%#Normal_foo#hello'
|
|
|
|
end
|
2013-09-19 03:31:39 +02:00
|
|
|
|
|
|
|
it 'should replace two accent groups with correct groups'
|
2013-09-22 21:20:06 +02:00
|
|
|
call s:builder.add_section('Normal', '%#__accent_foo#hello%#__accent_bar#world')
|
2013-09-19 03:31:39 +02:00
|
|
|
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
|
2014-11-22 17:52:54 +01:00
|
|
|
|
|
|
|
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
|
2013-08-31 03:28:38 +02:00
|
|
|
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')
|
2014-10-18 19:59:24 +02:00
|
|
|
call s:builder.add_section('Search', 'world')
|
2013-08-31 03:28:38 +02:00
|
|
|
let stl = s:builder.build()
|
2014-10-18 19:59:24 +02:00
|
|
|
Expect stl =~ '%#Normal_inactive#hello%#Normal_to_Search_inactive#>%#Search_inactive#world'
|
2013-08-31 03:28:38 +02:00
|
|
|
end
|
2013-09-22 23:15:02 +02:00
|
|
|
|
|
|
|
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
|
2013-08-31 03:28:38 +02:00
|
|
|
end
|
|
|
|
|