/ test / handler / test_yamllint_handler.vader
test_yamllint_handler.vader
 1  Before:
 2    Save g:ale_warn_about_trailing_whitespace
 3  
 4    let g:ale_warn_about_trailing_whitespace = 1
 5  
 6    runtime! ale/handlers/yamllint.vim
 7  
 8  After:
 9    Restore
10  
11    unlet! b:ale_warn_about_trailing_whitespace
12  
13    call ale#linter#Reset()
14  
15  Execute(Problems should be parsed correctly for yamllint):
16    AssertEqual
17    \ [
18    \   {
19    \     'lnum': 1,
20    \     'col': 1,
21    \     'type': 'W',
22    \     'text': 'missing document start "---"',
23    \     'code': 'document-start',
24    \   },
25    \   {
26    \     'lnum': 2,
27    \     'col': 1,
28    \     'type': 'E',
29    \     'text': 'syntax error: expected the node content, but found ''<stream end>''',
30    \   },
31    \ ],
32    \ ale#handlers#yamllint#Handle(bufnr(''), [
33    \   'something.yaml:1:1: [warning] missing document start "---" (document-start)',
34    \   'something.yml:2:1: [error] syntax error: expected the node content, but found ''<stream end>''',
35    \ ])
36  
37  Execute(The yamllint handler should respect ale_warn_about_trailing_whitespace):
38    AssertEqual
39    \ [
40    \   {
41    \     'lnum': 5,
42    \     'col': 18,
43    \     'type': 'E',
44    \     'text': 'trailing spaces',
45    \     'code': 'trailing-spaces',
46    \   },
47    \ ],
48    \ ale#handlers#yamllint#Handle(bufnr(''), [
49    \   'something.yml:5:18: [error] trailing spaces (trailing-spaces)',
50    \ ])
51  
52    let b:ale_warn_about_trailing_whitespace = 0
53  
54    AssertEqual
55    \ [
56    \ ],
57    \ ale#handlers#yamllint#Handle(bufnr(''), [
58    \   'something.yml:5:18: [error] trailing spaces (trailing-spaces)',
59    \ ])