/ test / handler / test_embertemplatelint_handler.vader
test_embertemplatelint_handler.vader
 1  " Author: Adrian Zalewski <aazalewski@hotmail.com>
 2  Before:
 3    runtime autoload/ale/handlers/embertemplatelint.vim
 4  
 5  After:
 6    call ale#linter#Reset()
 7  
 8  Execute(The ember-template-lint handler should parse lines correctly):
 9    let input_lines = split('{
10    \ "/ember-project/app/templates/application.hbs": [
11    \   {
12    \     "moduleId": "app/templates/application",
13    \     "rule": "bare-strings",
14    \     "severity": 2,
15    \     "message": "Non-translated string used",
16    \     "line": 1,
17    \     "column": 10,
18    \     "source": " Bare String\n"
19    \   },
20    \   {
21    \     "moduleId": "app/templates/application",
22    \     "rule": "invalid-interactive",
23    \     "severity": 1,
24    \     "message": "Interaction added to non-interactive element",
25    \     "line": 3,
26    \     "column": 6,
27    \     "source": "<span {{action someAction}}></span>"
28    \   }
29    \ ]
30    \ }', '\n')
31  
32    AssertEqual
33    \ [
34    \   {
35    \     'lnum': 1,
36    \     'col': 10,
37    \     'text': 'bare-strings: Non-translated string used',
38    \     'type': 'E',
39    \   },
40    \   {
41    \     'lnum': 3,
42    \     'col': 6,
43    \     'text': 'invalid-interactive: Interaction added to non-interactive element',
44    \     'type': 'W',
45    \   },
46    \ ],
47    \ ale#handlers#embertemplatelint#Handle(347, input_lines)
48  
49  Execute(The ember-template-lint handler should handle template parsing error correctly):
50    let input_lines = split('{
51    \ "/ember-project/app/templates/application.hbs": [
52    \   {
53    \     "fatal": true,
54    \     "moduleId": "app/templates/application",
55    \     "message": "Parse error on line 5 ...",
56    \     "line": 5,
57    \     "column": 3,
58    \     "source": "Error: Parse error on line 5 ...",
59    \     "severity": 2
60    \   }
61    \ ]
62    \ }', '\n')
63  
64    AssertEqual
65    \ [
66    \   {
67    \     'lnum': 5,
68    \     'col': 3,
69    \     'text': 'Parse error on line 5 ...',
70    \     'type': 'E',
71    \   },
72    \ ],
73    \ ale#handlers#embertemplatelint#Handle(347, input_lines)
74  
75  Execute(The ember-template-lint handler should handle no lint errors/warnings):
76    AssertEqual
77    \ [],
78    \ ale#handlers#embertemplatelint#Handle(347, [])
79    AssertEqual
80    \ [],
81    \ ale#handlers#embertemplatelint#Handle(347, ['{}'])