2013-08-31 01:15:41 +00:00
|
|
|
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
|
|
|
|
|
2013-09-26 02:13:57 +00:00
|
|
|
it 'should be able to reference default parts'
|
|
|
|
let s = airline#section#create(['paste'])
|
|
|
|
Expect s == '%{airline#util#wrap(airline#parts#paste(),0)}'
|
|
|
|
end
|
|
|
|
|
2013-08-31 01:15:41 +00:00
|
|
|
it 'should create sections with no separators'
|
|
|
|
let s = airline#section#create(['text', 'raw', 'func'])
|
2013-08-31 16:33:58 +00:00
|
|
|
Expect s == '%{airline#util#wrap("text",0)}raw%{airline#util#wrap(SectionSpec(),0)}'
|
2013-08-31 01:15:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should create left sections with separators'
|
|
|
|
let s = airline#section#create_left(['text', 'text'])
|
2013-08-31 16:33:58 +00:00
|
|
|
Expect s == '%{airline#util#wrap("text",0)}%{airline#util#append("text",0)}'
|
2013-08-31 01:15:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should create right sections with separators'
|
|
|
|
let s = airline#section#create_right(['text', 'text'])
|
2013-08-31 16:33:58 +00:00
|
|
|
Expect s == '%{airline#util#prepend("text",0)}%{airline#util#wrap("text",0)}'
|
2013-08-31 01:15:41 +00:00
|
|
|
end
|
2013-08-31 03:26:59 +00:00
|
|
|
|
2013-09-23 15:45:44 +00:00
|
|
|
it 'should prefix with accent group if provided and restore afterwards'
|
2013-09-01 02:48:27 +00:00
|
|
|
call airline#parts#define('hi', {
|
|
|
|
\ 'raw': 'hello',
|
2013-09-16 02:47:13 +00:00
|
|
|
\ 'accent': 'red',
|
2013-09-01 02:48:27 +00:00
|
|
|
\ })
|
2013-08-31 03:26:59 +00:00
|
|
|
let s = airline#section#create(['hi'])
|
2013-09-23 15:45:44 +00:00
|
|
|
Expect s == '%#__accent_red#hello%#__restore__#'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should accent functions'
|
|
|
|
call airline#parts#define_function('hi', 'Hello')
|
|
|
|
call airline#parts#define_accent('hi', 'bold')
|
|
|
|
let s = airline#section#create(['hi'])
|
|
|
|
Expect s == '%#__accent_bold#%{airline#util#wrap(Hello(),0)}%#__restore__#'
|
2013-08-31 03:26:59 +00:00
|
|
|
end
|
2013-08-31 21:42:09 +00:00
|
|
|
|
2013-09-01 16:07:46 +00:00
|
|
|
it 'should parse out a section from the distro'
|
2013-09-26 02:13:57 +00:00
|
|
|
call airline#extensions#load()
|
2013-08-31 21:42:09 +00:00
|
|
|
let s = airline#section#create(['whitespace'])
|
|
|
|
Expect s =~ 'airline#extensions#whitespace#check'
|
|
|
|
end
|
2013-09-01 02:48:27 +00:00
|
|
|
|
|
|
|
it 'should use parts as is if they are not found'
|
|
|
|
let s = airline#section#create(['asdf', 'func'])
|
|
|
|
Expect s == 'asdf%{airline#util#wrap(SectionSpec(),0)}'
|
|
|
|
end
|
2013-09-01 16:07:46 +00:00
|
|
|
|
|
|
|
it 'should force add separators for raw and missing keys'
|
|
|
|
let s = airline#section#create_left(['asdf', 'raw'])
|
2013-09-30 14:37:02 +00:00
|
|
|
Expect s == 'asdf > raw'
|
2013-09-01 16:07:46 +00:00
|
|
|
let s = airline#section#create_left(['asdf', 'aaaa', 'raw'])
|
2013-09-30 14:37:02 +00:00
|
|
|
Expect s == 'asdf > aaaa > raw'
|
2013-09-01 16:07:46 +00:00
|
|
|
let s = airline#section#create_right(['raw', '%f'])
|
2013-09-30 14:37:02 +00:00
|
|
|
Expect s == 'raw < %f'
|
2013-09-01 16:07:46 +00:00
|
|
|
let s = airline#section#create_right(['%t', 'asdf', '%{getcwd()}'])
|
2013-09-30 14:37:02 +00:00
|
|
|
Expect s == '%t < asdf < %{getcwd()}'
|
2013-09-01 16:07:46 +00:00
|
|
|
end
|
2013-09-08 23:06:57 +00:00
|
|
|
|
|
|
|
it 'should empty out parts that do not pass their condition'
|
|
|
|
call airline#parts#define_text('conditional', 'conditional')
|
|
|
|
call airline#parts#define_condition('conditional', '0')
|
|
|
|
let s = airline#section#create(['conditional'])
|
|
|
|
Expect s == '%{0 ? airline#util#wrap("conditional",0) : ""}'
|
|
|
|
end
|
2016-08-01 19:00:47 +00:00
|
|
|
|
|
|
|
it 'should not draw two separators after another'
|
|
|
|
let s = airline#section#create_right(['ffenc','%{strftime("%H:%M")}'])
|
|
|
|
Expect s == '%{airline#util#prepend(airline#parts#ffenc(),0)}%{strftime("%H:%M")}'
|
|
|
|
end
|
2013-08-31 01:15:41 +00:00
|
|
|
end
|
|
|
|
|