Add some tests for the EchoCursorWarning function.
This commit is contained in:
parent
1e756c0e24
commit
56b866c8d8
@ -1,25 +1,33 @@
|
||||
Before:
|
||||
let g:ale_buffer_loclist_map = {}
|
||||
|
||||
After:
|
||||
let g:ale_buffer_loclist_map = {}
|
||||
|
||||
Execute (Count should be 0 when data is empty):
|
||||
AssertEqual ale#statusline#Count(bufnr('%')), [0, 0]
|
||||
|
||||
|
||||
Before:
|
||||
let g:ale_buffer_count_map = {'44': [1, 2]}
|
||||
|
||||
After:
|
||||
let g:ale_buffer_loclist_map = {}
|
||||
|
||||
Execute (Count should read data from the cache):
|
||||
AssertEqual ale#statusline#Count(44), [1, 2]
|
||||
|
||||
Execute (Update the cache with new data):
|
||||
call ale#statusline#Update(44, [])
|
||||
|
||||
Then (The cache should reflect the new data):
|
||||
AssertEqual ale#statusline#Count(44), [0, 0]
|
||||
|
||||
|
||||
Before:
|
||||
let g:ale_buffer_loclist_map = {'1': [{'lnum': 1, 'bufnr': 1, 'vcol': 0, 'linter_name': 'testlinter', 'nr': -1, 'type': 'E', 'col': 1, 'text': 'Test Error'}]}
|
||||
|
||||
After:
|
||||
let g:ale_buffer_loclist_map = {}
|
||||
|
||||
Execute (Count should be match the loclist):
|
||||
AssertEqual ale#statusline#Count(1), [1, 0]
|
||||
|
||||
@ -29,22 +37,29 @@ Execute (Output should be empty for non-existant buffer):
|
||||
Before:
|
||||
let g:ale_statusline_format = ['%sE', '%sW', 'OKIE']
|
||||
|
||||
After:
|
||||
let g:ale_buffer_loclist_map = {}
|
||||
|
||||
Execute (Given some errors):
|
||||
call ale#statusline#Update(bufnr('%'), [{'type': 'E'}, {'type': 'E'}])
|
||||
|
||||
Then (Statusline is formatted to the users preference):
|
||||
AssertEqual ale#statusline#Status(), "2E"
|
||||
|
||||
Execute (Given some warnings):
|
||||
call ale#statusline#Update(bufnr('%'), [{'type': 'W'}, {'type': 'W'}, {'type': 'W'}])
|
||||
|
||||
Then (Statusline is formatted to the users preference):
|
||||
AssertEqual ale#statusline#Status(), "3W"
|
||||
|
||||
Execute (Given some warnings, and errors.):
|
||||
call ale#statusline#Update(bufnr('%'), [{'type': 'E'}, {'type': 'W'}, {'type': 'W'}])
|
||||
|
||||
Then (Statusline is formatted to the users preference):
|
||||
AssertEqual ale#statusline#Status(), "1E 2W"
|
||||
|
||||
Execute (Given a lack of data):
|
||||
call ale#statusline#Update(bufnr('%'), [])
|
||||
|
||||
Then (Statusline is formatted to the users preference):
|
||||
AssertEqual ale#statusline#Status(), 'OKIE'
|
||||
|
84
test/test_cursor_warnings.vader
Normal file
84
test/test_cursor_warnings.vader
Normal file
@ -0,0 +1,84 @@
|
||||
Before:
|
||||
let g:ale_buffer_loclist_map = {
|
||||
\ bufnr('%'): [
|
||||
\ {
|
||||
\ 'lnum': 1,
|
||||
\ 'bufnr': bufnr('%'),
|
||||
\ 'vcol': 0,
|
||||
\ 'linter_name': 'eslint',
|
||||
\ 'nr': -1,
|
||||
\ 'type': 'E',
|
||||
\ 'col': 10,
|
||||
\ 'text': 'Missing semicolon. (semi)'
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 2,
|
||||
\ 'bufnr': bufnr('%'),
|
||||
\ 'vcol': 0,
|
||||
\ 'linter_name': 'eslint',
|
||||
\ 'nr': -1,
|
||||
\ 'type': 'W',
|
||||
\ 'col': 10,
|
||||
\ 'text': 'Infix operators must be spaced. (space-infix-ops)'
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 2,
|
||||
\ 'bufnr': bufnr('%'),
|
||||
\ 'vcol': 0,
|
||||
\ 'linter_name': 'eslint',
|
||||
\ 'nr': -1,
|
||||
\ 'type': 'E',
|
||||
\ 'col': 15,
|
||||
\ 'text': 'Missing radix parameter (radix)'
|
||||
\ }
|
||||
\ ],
|
||||
\}
|
||||
|
||||
After:
|
||||
unlet! g:output
|
||||
unlet! g:lines
|
||||
let g:ale_buffer_loclist_map = {}
|
||||
|
||||
Given javascript(A Javscript file with warnings/errors):
|
||||
var x = 3
|
||||
var x = 5*2 + parseInt("10");
|
||||
|
||||
Execute(Evaluate the cursor function at line 1):
|
||||
:1
|
||||
call ale#cursor#EchoCursorWarning()
|
||||
|
||||
Then(Check the cursor output):
|
||||
redir => g:output
|
||||
:mess
|
||||
redir END
|
||||
|
||||
let g:lines = split(g:output, "\n")
|
||||
|
||||
AssertEqual 'Missing semicolon. (semi)', g:lines[-1]
|
||||
|
||||
Execute(Evaluate the cursor function at line 2):
|
||||
:2
|
||||
call ale#cursor#EchoCursorWarning()
|
||||
|
||||
Then(Check the cursor output):
|
||||
redir => g:output
|
||||
:mess
|
||||
redir END
|
||||
|
||||
let g:lines = split(g:output, "\n")
|
||||
|
||||
AssertEqual 'Infix operators must be spaced. (space-infix-ops)', g:lines[-1]
|
||||
|
||||
Execute(Evaluate the cursor function later in line 2):
|
||||
:2
|
||||
normal 16l
|
||||
call ale#cursor#EchoCursorWarning()
|
||||
|
||||
Then(Check the cursor output):
|
||||
redir => g:output
|
||||
:mess
|
||||
redir END
|
||||
|
||||
let g:lines = split(g:output, "\n")
|
||||
|
||||
AssertEqual 'Missing radix parameter (radix)', g:lines[-1]
|
Loading…
Reference in New Issue
Block a user