aboutsummaryrefslogtreecommitdiff
path: root/vim/bundle/lightline.vim/test/tabs.vim
blob: 92c2c08fc5793dfd847067728e0485f50b91ff11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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