summaryrefslogtreecommitdiff
path: root/test/test_statusline.vader
blob: 05e60479fe209a6a79e05c5ef5151255b398daab (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
Before:
  let g:ale_statusline_format = ['%sE', '%sW', 'OKIE']

After:
  let g:ale_buffer_info = {}

Execute (Count should be 0 when data is empty):
  let g:ale_buffer_info = {}
  AssertEqual [0, 0], ale#statusline#Count(bufnr('%'))

Execute (Count should read data from the cache):
  let g:ale_buffer_info = {'44': {'count': [1, 2]}}
  AssertEqual [1, 2], ale#statusline#Count(44)

Execute (The count should be correct after an update):
  let g:ale_buffer_info = {'44': {}}
  call ale#statusline#Update(44, [])
  AssertEqual [0, 0], ale#statusline#Count(44)

Execute (Count should be match the loclist):
  let g:ale_buffer_info = {
  \ bufnr('%'): {
  \   'loclist': [
  \     {
  \       'lnum': 1,
  \       'bufnr': 1,
  \       'vcol': 0,
  \       'linter_name': 'testlinter',
  \       'nr': -1,
  \       'type': 'E',
  \       'col': 1,
  \       'text': 'Test Error',
  \     },
  \   ],
  \ },
  \}
  AssertEqual [1, 0], ale#statusline#Count(bufnr('%'))

Execute (Output should be empty for non-existant buffer):
  AssertEqual [0, 0], ale#statusline#Count(9001)

Execute (Statusline is formatted to the users preference for just errors):
  let g:ale_buffer_info = {bufnr('%'): {}}
  call ale#statusline#Update(bufnr('%'), [{'type': 'E'}, {'type': 'E'}])
  AssertEqual '2E', ale#statusline#Status()

Execute (Statusline is formatted to the users preference for just warnings):
  let g:ale_buffer_info = {bufnr('%'): {}}
  call ale#statusline#Update(bufnr('%'), [{'type': 'W'}, {'type': 'W'}, {'type': 'W'}])
  AssertEqual '3W', ale#statusline#Status()

Execute (Statusline is formatted to the users preference for errors and warnings):
  let g:ale_buffer_info = {bufnr('%'): {}}
  call ale#statusline#Update(bufnr('%'), [{'type': 'E'}, {'type': 'W'}, {'type': 'W'}])
  AssertEqual '1E 2W', ale#statusline#Status()

Execute (Statusline is formatted to the users preference for no errors or warnings):
  let g:ale_buffer_info = {bufnr('%'): {}}
  call ale#statusline#Update(bufnr('%'), [])
  AssertEqual 'OKIE', ale#statusline#Status()