test creation of sections
This commit is contained in:
parent
54ec1f39ca
commit
f5885bf9c2
@ -2,7 +2,6 @@
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
function! s:get_val(key, append)
|
||||
let val = ''
|
||||
let part = airline#parts#get(a:key)
|
||||
if exists('part.function')
|
||||
let func = (part.function).'()'
|
||||
@ -14,12 +13,13 @@ function! s:get_val(key, append)
|
||||
return a:key
|
||||
endif
|
||||
|
||||
let val = ''
|
||||
if a:append > 0
|
||||
let val .= '%{airline#util#append('.func.')}'
|
||||
elseif a:append < 0
|
||||
return '%{airline#util#prepend('.func.')}'
|
||||
let val .= '%{airline#util#prepend('.func.')}'
|
||||
else
|
||||
return '%{'.func.'}'
|
||||
let val .= '%{'.func.'}'
|
||||
endif
|
||||
return val
|
||||
endfunction
|
||||
|
24
t/parts.vim
Normal file
24
t/parts.vim
Normal file
@ -0,0 +1,24 @@
|
||||
describe 'parts'
|
||||
it 'overwrites existing values'
|
||||
call airline#parts#define('foo', { 'test': '123' })
|
||||
Expect airline#parts#get('foo').test == '123'
|
||||
call airline#parts#define('foo', { 'test': '321' })
|
||||
Expect airline#parts#get('foo').test == '321'
|
||||
end
|
||||
|
||||
it 'can define a function part'
|
||||
call airline#parts#define_function('func', 'bar')
|
||||
Expect airline#parts#get('func').function == 'bar'
|
||||
end
|
||||
|
||||
it 'can define a text part'
|
||||
call airline#parts#define_text('text', 'bar')
|
||||
Expect airline#parts#get('text').text == 'bar'
|
||||
end
|
||||
|
||||
it 'can define a raw part'
|
||||
call airline#parts#define_raw('raw', 'bar')
|
||||
Expect airline#parts#get('raw').raw == 'bar'
|
||||
end
|
||||
end
|
||||
|
28
t/section.vim
Normal file
28
t/section.vim
Normal file
@ -0,0 +1,28 @@
|
||||
call airline#init#bootstrap()
|
||||
|
||||
function! SectionSpec()
|
||||
endfunction
|
||||
|
||||
describe 'section'
|
||||
before
|
||||
call airline#parts#define_text('text', 'text')
|
||||
call airline#parts#define_raw('raw', 'raw')
|
||||
call airline#parts#define_function('func', 'SectionSpec')
|
||||
end
|
||||
|
||||
it 'should create sections with no separators'
|
||||
let s = airline#section#create(['text', 'raw', 'func'])
|
||||
Expect s == '%{"text"}raw%{SectionSpec()}'
|
||||
end
|
||||
|
||||
it 'should create left sections with separators'
|
||||
let s = airline#section#create_left(['text', 'text'])
|
||||
Expect s == '%{"text"}%{airline#util#append("text")}'
|
||||
end
|
||||
|
||||
it 'should create right sections with separators'
|
||||
let s = airline#section#create_right(['text', 'text'])
|
||||
Expect s == '%{airline#util#prepend("text")}%{"text"}'
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user