summaryrefslogtreecommitdiff
path: root/test/handler/test_embertemplatelint_handler.vader
blob: d5394baf3d3c343e7b567dbb4373df6f29ed5e99 (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
" Author: Adrian Zalewski <aazalewski@hotmail.com>
Before:
  runtime autoload/ale/handlers/embertemplatelint.vim

After:
  call ale#linter#Reset()

Execute(The ember-template-lint handler should parse lines correctly):
  let input_lines = split('{
  \ "/ember-project/app/templates/application.hbs": [
  \   {
  \     "moduleId": "app/templates/application",
  \     "rule": "bare-strings",
  \     "severity": 2,
  \     "message": "Non-translated string used",
  \     "line": 1,
  \     "column": 10,
  \     "source": " Bare String\n"
  \   },
  \   {
  \     "moduleId": "app/templates/application",
  \     "rule": "invalid-interactive",
  \     "severity": 1,
  \     "message": "Interaction added to non-interactive element",
  \     "line": 3,
  \     "column": 6,
  \     "source": "<span {{action someAction}}></span>"
  \   }
  \ ]
  \ }', '\n')

  AssertEqual
  \ [
  \   {
  \     'lnum': 1,
  \     'col': 10,
  \     'text': 'bare-strings: Non-translated string used',
  \     'type': 'E',
  \   },
  \   {
  \     'lnum': 3,
  \     'col': 6,
  \     'text': 'invalid-interactive: Interaction added to non-interactive element',
  \     'type': 'W',
  \   },
  \ ],
  \ ale#handlers#embertemplatelint#Handle(347, input_lines)

Execute(The ember-template-lint handler should handle template parsing error correctly):
  let input_lines = split('{
  \ "/ember-project/app/templates/application.hbs": [
  \   {
  \     "fatal": true,
  \     "moduleId": "app/templates/application",
  \     "message": "Parse error on line 5 ...",
  \     "line": 5,
  \     "column": 3,
  \     "source": "Error: Parse error on line 5 ...",
  \     "severity": 2
  \   }
  \ ]
  \ }', '\n')

  AssertEqual
  \ [
  \   {
  \     'lnum': 5,
  \     'col': 3,
  \     'text': 'Parse error on line 5 ...',
  \     'type': 'E',
  \   },
  \ ],
  \ ale#handlers#embertemplatelint#Handle(347, input_lines)

Execute(The ember-template-lint handler should handle no lint errors/warnings):
  AssertEqual
  \ [],
  \ ale#handlers#embertemplatelint#Handle(347, [])
  AssertEqual
  \ [],
  \ ale#handlers#embertemplatelint#Handle(347, ['{}'])