mirror of
https://github.com/itchyny/lightline.vim.git
synced 2025-11-12 13:33:50 -05:00
split tests per functions
This commit is contained in:
77
test/onetab.vim
Normal file
77
test/onetab.vim
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
let s:suite = themis#suite('onetab')
|
||||||
|
let s:assert = themis#helper('assert')
|
||||||
|
|
||||||
|
function! s:suite.before_each()
|
||||||
|
let g:lightline = {}
|
||||||
|
call lightline#init()
|
||||||
|
tabnew
|
||||||
|
tabonly
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:suite.onetab()
|
||||||
|
call s:assert.equals(lightline#onetab(1, 1), '1 [No Name]')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:suite.tabnew()
|
||||||
|
tabnew
|
||||||
|
call s:assert.equals(lightline#onetab(1, 0), '1 [No Name]')
|
||||||
|
call s:assert.equals(lightline#onetab(2, 1), '2 [No Name]')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:suite.tabnew_tabnew()
|
||||||
|
tabnew
|
||||||
|
tabnew
|
||||||
|
call s:assert.equals(lightline#onetab(1, 0), '1 [No Name]')
|
||||||
|
call s:assert.equals(lightline#onetab(2, 0), '2 [No Name]')
|
||||||
|
call s:assert.equals(lightline#onetab(3, 1), '3 [No Name]')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:suite.modified()
|
||||||
|
call append(0, '')
|
||||||
|
call s:assert.equals(lightline#onetab(1, 1), '1 [No Name] +')
|
||||||
|
undo
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:suite.filename()
|
||||||
|
edit test
|
||||||
|
call s:assert.equals(lightline#onetab(1, 1), '1 test')
|
||||||
|
tabnew
|
||||||
|
bunload test
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:suite.filename_modified()
|
||||||
|
edit test
|
||||||
|
call append(0, '')
|
||||||
|
call s:assert.equals(lightline#onetab(1, 1), '1 test +')
|
||||||
|
tabnew
|
||||||
|
bunload! test
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:suite.active_inactive()
|
||||||
|
let g:lightline = { 'tab': { 'active': [ 'tabnum', 'filename' ], 'inactive': [ 'filename' ] } }
|
||||||
|
call lightline#init()
|
||||||
|
edit test
|
||||||
|
call append(0, '')
|
||||||
|
call s:assert.equals(lightline#onetab(1, 1), '1 test')
|
||||||
|
call s:assert.equals(lightline#onetab(1, 0), 'test')
|
||||||
|
tabnew
|
||||||
|
bunload! test
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:suite.tab_component()
|
||||||
|
let g:lightline = { 'tab': { 'active': [ 'custom' ] }, 'tab_component': { 'custom': 'custom' } }
|
||||||
|
call lightline#init()
|
||||||
|
call s:assert.equals(lightline#onetab(1, 1), 'custom')
|
||||||
|
call s:assert.equals(lightline#onetab(2, 1), 'custom')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:suite.tab_component_function()
|
||||||
|
function! Custom(n)
|
||||||
|
return 'custom: ' . a:n
|
||||||
|
endfunction
|
||||||
|
let g:lightline = { 'tab': { 'active': [ 'custom' ] }, 'tab_component_function': { 'custom': 'Custom' } }
|
||||||
|
call lightline#init()
|
||||||
|
call s:assert.equals(lightline#onetab(1, 1), 'custom: 1')
|
||||||
|
call s:assert.equals(lightline#onetab(2, 1), 'custom: 2')
|
||||||
|
delfunction Custom
|
||||||
|
endfunction
|
||||||
164
test/tabline.vim
164
test/tabline.vim
@@ -2,7 +2,7 @@ let s:suite = themis#suite('tabline')
|
|||||||
let s:assert = themis#helper('assert')
|
let s:assert = themis#helper('assert')
|
||||||
|
|
||||||
function! s:suite.before_each()
|
function! s:suite.before_each()
|
||||||
let g:lightline = { 'winwidth': 180 }
|
let g:lightline = {}
|
||||||
call lightline#init()
|
call lightline#init()
|
||||||
tabnew
|
tabnew
|
||||||
tabonly
|
tabonly
|
||||||
@@ -12,172 +12,14 @@ function! s:suite.tabline()
|
|||||||
call s:assert.equals(&tabline, '%!lightline#tabline()')
|
call s:assert.equals(&tabline, '%!lightline#tabline()')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:suite.tabline_enabled()
|
function! s:suite.enabled()
|
||||||
let g:lightline = { 'enable': { 'tabline': 1 } }
|
let g:lightline = { 'enable': { 'tabline': 1 } }
|
||||||
call lightline#init()
|
call lightline#init()
|
||||||
call s:assert.equals(&tabline, '%!lightline#tabline()')
|
call s:assert.equals(&tabline, '%!lightline#tabline()')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:suite.tabline_disabled()
|
function! s:suite.disabled()
|
||||||
let g:lightline = { 'enable': { 'tabline': 0 } }
|
let g:lightline = { 'enable': { 'tabline': 0 } }
|
||||||
call lightline#init()
|
call lightline#init()
|
||||||
call s:assert.equals(&tabline, '')
|
call s:assert.equals(&tabline, '')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:tab(number, ...) abort
|
|
||||||
let active = get(a:000, 0, 0)
|
|
||||||
let last = get(a:000, 1, 0)
|
|
||||||
return '%' . a:number . 'T%{lightline#onetab(' . a:number . ',' . active . ')}' . (last ? '%T' : '')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:suite.init()
|
|
||||||
call s:assert.equals(lightline#tabs(), [[], [s:tab(1, 1, 1)], []])
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:suite.tabnew()
|
|
||||||
tabnew
|
|
||||||
call s:assert.equals(lightline#tabs(), [[s:tab(1)], [s:tab(2, 1, 1)], []])
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:suite.tabnew_tabnew()
|
|
||||||
tabnew
|
|
||||||
tabnew
|
|
||||||
call s:assert.equals(lightline#tabs(), [[s:tab(1), s:tab(2)], [s:tab(3, 1, 1)], []])
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:suite.tabnew_tabfirst()
|
|
||||||
tabnew
|
|
||||||
tabfirst
|
|
||||||
call s:assert.equals(lightline#tabs(), [[], [s:tab(1, 1)], [s:tab(2, 0, 1)]])
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:suite.tabnew_tabnew_tabfirst()
|
|
||||||
tabnew
|
|
||||||
tabnew
|
|
||||||
tabfirst
|
|
||||||
call s:assert.equals(lightline#tabs(), [[], [s:tab(1, 1)], [s:tab(2), s:tab(3, 0, 1)]])
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:suite.tabnew_tabnew_tabprevious()
|
|
||||||
tabnew
|
|
||||||
tabnew
|
|
||||||
tabprevious
|
|
||||||
call s:assert.equals(lightline#tabs(), [[s:tab(1)], [s:tab(2, 1)], [s:tab(3, 0, 1)]])
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:suite.tabnew_20()
|
|
||||||
for i in range(19)
|
|
||||||
tabnew
|
|
||||||
endfor
|
|
||||||
call s:assert.equals(lightline#tabs(), [[s:tab(1), s:tab(2), s:tab(3), s:tab(4), '...', s:tab(16), s:tab(17), s:tab(18), s:tab(19)], [s:tab(20, 1, 1)], []])
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:suite.tabnew_20_tabfirst()
|
|
||||||
for i in range(19)
|
|
||||||
tabnew
|
|
||||||
endfor
|
|
||||||
tabfirst
|
|
||||||
call s:assert.equals(lightline#tabs(), [[], [s:tab(1, 1)], [s:tab(2), s:tab(3), s:tab(4), s:tab(5), '...', s:tab(17), s:tab(18), s:tab(19), s:tab(20, 0, 1)]])
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:suite.tabnew_20_tabfirst_tabnext()
|
|
||||||
for i in range(19)
|
|
||||||
tabnew
|
|
||||||
endfor
|
|
||||||
tabfirst
|
|
||||||
tabnext
|
|
||||||
call s:assert.equals(lightline#tabs(), [[s:tab(1)], [s:tab(2, 1)], [s:tab(3), s:tab(4), s:tab(5), s:tab(6), '...', s:tab(18), s:tab(19), s:tab(20, 0, 1)]])
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:suite.tabnew_20_tabnext_10()
|
|
||||||
for i in range(19)
|
|
||||||
tabnew
|
|
||||||
endfor
|
|
||||||
tabnext 10
|
|
||||||
call s:assert.equals(lightline#tabs(), [[s:tab(1), s:tab(2), '...', s:tab(8), s:tab(9)], [s:tab(10, 1)], [s:tab(11), s:tab(12), '...', s:tab(19), s:tab(20, 0, 1)]])
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:suite.tabnew_20_tabprevious()
|
|
||||||
for i in range(19)
|
|
||||||
tabnew
|
|
||||||
endfor
|
|
||||||
tabprevious
|
|
||||||
call s:assert.equals(lightline#tabs(), [[s:tab(1), s:tab(2), s:tab(3), '...', s:tab(15), s:tab(16), s:tab(17), s:tab(18)], [s:tab(19, 1)], [s:tab(20, 0, 1)]])
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:suite.tabnew_20_tabprevious_tabprevious()
|
|
||||||
for i in range(19)
|
|
||||||
tabnew
|
|
||||||
endfor
|
|
||||||
tabprevious
|
|
||||||
tabprevious
|
|
||||||
call s:assert.equals(lightline#tabs(), [[s:tab(1), s:tab(2), s:tab(3), '...', s:tab(15), s:tab(16), s:tab(17)], [s:tab(18, 1)], [s:tab(19), s:tab(20, 0, 1)]])
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:suite.onetab()
|
|
||||||
call s:assert.equals(lightline#onetab(1, 1), '1 [No Name]')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:suite.onetab_tabnew()
|
|
||||||
tabnew
|
|
||||||
call s:assert.equals(lightline#onetab(1, 0), '1 [No Name]')
|
|
||||||
call s:assert.equals(lightline#onetab(2, 1), '2 [No Name]')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:suite.onetab_tabnew_tabnew()
|
|
||||||
tabnew
|
|
||||||
tabnew
|
|
||||||
call s:assert.equals(lightline#onetab(1, 0), '1 [No Name]')
|
|
||||||
call s:assert.equals(lightline#onetab(2, 0), '2 [No Name]')
|
|
||||||
call s:assert.equals(lightline#onetab(3, 1), '3 [No Name]')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:suite.onetab_modified()
|
|
||||||
call append(0, '')
|
|
||||||
call s:assert.equals(lightline#onetab(1, 1), '1 [No Name] +')
|
|
||||||
undo
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:suite.onetab_filename()
|
|
||||||
edit test
|
|
||||||
call s:assert.equals(lightline#onetab(1, 1), '1 test')
|
|
||||||
tabnew
|
|
||||||
bunload test
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:suite.onetab_filename_modified()
|
|
||||||
edit test
|
|
||||||
call append(0, '')
|
|
||||||
call s:assert.equals(lightline#onetab(1, 1), '1 test +')
|
|
||||||
tabnew
|
|
||||||
bunload! test
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:suite.onetab_active_inactive()
|
|
||||||
let g:lightline = { 'tab': { 'active': [ 'tabnum', 'filename' ], 'inactive': [ 'filename' ] } }
|
|
||||||
call lightline#init()
|
|
||||||
edit test
|
|
||||||
call append(0, '')
|
|
||||||
call s:assert.equals(lightline#onetab(1, 1), '1 test')
|
|
||||||
call s:assert.equals(lightline#onetab(1, 0), 'test')
|
|
||||||
tabnew
|
|
||||||
bunload! test
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:suite.tab_component()
|
|
||||||
let g:lightline = { 'tab': { 'active': [ 'custom' ] }, 'tab_component': { 'custom': 'custom' } }
|
|
||||||
call lightline#init()
|
|
||||||
call s:assert.equals(lightline#onetab(1, 1), 'custom')
|
|
||||||
call s:assert.equals(lightline#onetab(2, 1), 'custom')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:suite.tab_component_function()
|
|
||||||
function! Custom(n)
|
|
||||||
return 'custom: ' . a:n
|
|
||||||
endfunction
|
|
||||||
let g:lightline = { 'tab': { 'active': [ 'custom' ] }, 'tab_component_function': { 'custom': 'Custom' } }
|
|
||||||
call lightline#init()
|
|
||||||
call s:assert.equals(lightline#onetab(1, 1), 'custom: 1')
|
|
||||||
call s:assert.equals(lightline#onetab(2, 1), 'custom: 2')
|
|
||||||
delfunction Custom
|
|
||||||
endfunction
|
|
||||||
|
|||||||
99
test/tabs.vim
Normal file
99
test/tabs.vim
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
let s:suite = themis#suite('tabs')
|
||||||
|
let s:assert = themis#helper('assert')
|
||||||
|
|
||||||
|
function! s:suite.before_each()
|
||||||
|
let g:lightline = { 'winwidth': 180 }
|
||||||
|
call lightline#init()
|
||||||
|
tabnew
|
||||||
|
tabonly
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:tab(number, ...) abort
|
||||||
|
let active = get(a:000, 0, 0)
|
||||||
|
let last = get(a:000, 1, 0)
|
||||||
|
return '%' . a:number . 'T%{lightline#onetab(' . a:number . ',' . active . ')}' . (last ? '%T' : '')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:suite.tabs()
|
||||||
|
call s:assert.equals(lightline#tabs(), [[], [s:tab(1, 1, 1)], []])
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:suite.tabnew()
|
||||||
|
tabnew
|
||||||
|
call s:assert.equals(lightline#tabs(), [[s:tab(1)], [s:tab(2, 1, 1)], []])
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:suite.tabnew_tabnew()
|
||||||
|
tabnew
|
||||||
|
tabnew
|
||||||
|
call s:assert.equals(lightline#tabs(), [[s:tab(1), s:tab(2)], [s:tab(3, 1, 1)], []])
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:suite.tabnew_tabfirst()
|
||||||
|
tabnew
|
||||||
|
tabfirst
|
||||||
|
call s:assert.equals(lightline#tabs(), [[], [s:tab(1, 1)], [s:tab(2, 0, 1)]])
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:suite.tabnew_tabnew_tabfirst()
|
||||||
|
tabnew
|
||||||
|
tabnew
|
||||||
|
tabfirst
|
||||||
|
call s:assert.equals(lightline#tabs(), [[], [s:tab(1, 1)], [s:tab(2), s:tab(3, 0, 1)]])
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:suite.tabnew_tabnew_tabprevious()
|
||||||
|
tabnew
|
||||||
|
tabnew
|
||||||
|
tabprevious
|
||||||
|
call s:assert.equals(lightline#tabs(), [[s:tab(1)], [s:tab(2, 1)], [s:tab(3, 0, 1)]])
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:suite.tabnew_20()
|
||||||
|
for i in range(19)
|
||||||
|
tabnew
|
||||||
|
endfor
|
||||||
|
call s:assert.equals(lightline#tabs(), [[s:tab(1), s:tab(2), s:tab(3), s:tab(4), '...', s:tab(16), s:tab(17), s:tab(18), s:tab(19)], [s:tab(20, 1, 1)], []])
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:suite.tabnew_20_tabfirst()
|
||||||
|
for i in range(19)
|
||||||
|
tabnew
|
||||||
|
endfor
|
||||||
|
tabfirst
|
||||||
|
call s:assert.equals(lightline#tabs(), [[], [s:tab(1, 1)], [s:tab(2), s:tab(3), s:tab(4), s:tab(5), '...', s:tab(17), s:tab(18), s:tab(19), s:tab(20, 0, 1)]])
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:suite.tabnew_20_tabfirst_tabnext()
|
||||||
|
for i in range(19)
|
||||||
|
tabnew
|
||||||
|
endfor
|
||||||
|
tabfirst
|
||||||
|
tabnext
|
||||||
|
call s:assert.equals(lightline#tabs(), [[s:tab(1)], [s:tab(2, 1)], [s:tab(3), s:tab(4), s:tab(5), s:tab(6), '...', s:tab(18), s:tab(19), s:tab(20, 0, 1)]])
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:suite.tabnew_20_tabnext_10()
|
||||||
|
for i in range(19)
|
||||||
|
tabnew
|
||||||
|
endfor
|
||||||
|
tabnext 10
|
||||||
|
call s:assert.equals(lightline#tabs(), [[s:tab(1), s:tab(2), '...', s:tab(8), s:tab(9)], [s:tab(10, 1)], [s:tab(11), s:tab(12), '...', s:tab(19), s:tab(20, 0, 1)]])
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:suite.tabnew_20_tabprevious()
|
||||||
|
for i in range(19)
|
||||||
|
tabnew
|
||||||
|
endfor
|
||||||
|
tabprevious
|
||||||
|
call s:assert.equals(lightline#tabs(), [[s:tab(1), s:tab(2), s:tab(3), '...', s:tab(15), s:tab(16), s:tab(17), s:tab(18)], [s:tab(19, 1)], [s:tab(20, 0, 1)]])
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:suite.tabnew_20_tabprevious_tabprevious()
|
||||||
|
for i in range(19)
|
||||||
|
tabnew
|
||||||
|
endfor
|
||||||
|
tabprevious
|
||||||
|
tabprevious
|
||||||
|
call s:assert.equals(lightline#tabs(), [[s:tab(1), s:tab(2), s:tab(3), '...', s:tab(15), s:tab(16), s:tab(17)], [s:tab(18, 1)], [s:tab(19), s:tab(20, 0, 1)]])
|
||||||
|
endfunction
|
||||||
@@ -8,7 +8,7 @@ function! s:suite.before_each()
|
|||||||
tabonly
|
tabonly
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:suite.init()
|
function! s:suite.default()
|
||||||
call s:assert.equals(exists('#lightline'), 1)
|
call s:assert.equals(exists('#lightline'), 1)
|
||||||
call s:assert.equals(exists('#lightline-disable'), 0)
|
call s:assert.equals(exists('#lightline-disable'), 0)
|
||||||
call s:assert.not_equals(&tabline, '')
|
call s:assert.not_equals(&tabline, '')
|
||||||
|
|||||||
Reference in New Issue
Block a user