summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFlorian Beeres <yuuki@protonmail.com>2017-11-11 13:07:08 +0100
committerw0rp <w0rp@users.noreply.github.com>2017-11-11 12:07:08 +0000
commit1ddc3eec6dff1c35111d47ec6e46cf2f2f699e20 (patch)
tree30a53cfac911c396acd77ad13445102a876cb1e9 /test
parentbb271859efa503a4f4546b5df1987dd579d4efb1 (diff)
downloadale-1ddc3eec6dff1c35111d47ec6e46cf2f2f699e20.zip
Handle flow extra errors (#946)
Show more information for Flow errors with :ALEDetail
Diffstat (limited to 'test')
-rw-r--r--test/handler/test_flow_handler.vader156
1 files changed, 154 insertions, 2 deletions
diff --git a/test/handler/test_flow_handler.vader b/test/handler/test_flow_handler.vader
index 47efc30d..3a575a01 100644
--- a/test/handler/test_flow_handler.vader
+++ b/test/handler/test_flow_handler.vader
@@ -243,7 +243,7 @@ Execute(The flow handler should fetch the correct location for the currently ope
\ 'lnum': 6,
\ 'col': 3,
\ 'type': 'E',
- \ 'text': 'property `bar`: Property not found in props of React element `Foo` See also: React element `Foo`'
+ \ 'text': 'property `bar`: Property not found in props of React element `Foo` See also: React element `Foo`',
\ }
\]
@@ -347,7 +347,159 @@ Execute(The flow handler should handle relative paths):
\ 'lnum': 6,
\ 'col': 3,
\ 'type': 'E',
- \ 'text': 'property `bar`: Property not found in props of React element `Foo` See also: React element `Foo`'
+ \ 'text': 'property `bar`: Property not found in props of React element `Foo` See also: React element `Foo`',
+ \ }
+ \]
+
+ AssertEqual g:expected, g:actual
+
+Execute(The flow handler should handle extra errors):
+ silent! noautocmd file /Users/rav/Projects/vim-ale-flow/index.js
+
+ let g:flow_output = {
+ \ "flowVersion": "0.54.0",
+ \ "errors": [{
+ \ "extra": [{
+ \ "message": [{
+ \ "context": v:null,
+ \ "descr": "Property \`setVector\` is incompatible:",
+ \ "type": "Blame ",
+ \ "path": "",
+ \ "line": 0,
+ \ "endline": 0,
+ \ "start": 1,
+ \ "end": 0
+ \ }],
+ \ "children": [{
+ \ "message": [{
+ \ "context": "setVector = \{2\}",
+ \ "descr": "number ",
+ \ "type": "Blame ",
+ \ "loc": {
+ \ "source": expand('%:p'),
+ \ "type": "SourceFile ",
+ \ "start": {
+ \ "line": 90,
+ \ "column": 30,
+ \ "offset": 2296
+ \ },
+ \ "end": {
+ \ "line": 90,
+ \ "column": 30,
+ \ "offset": 2297
+ \ }
+ \ },
+ \ "path": expand('%:p'),
+ \ "line": 90,
+ \ "endline": 90,
+ \ "start": 30,
+ \ "end": 30
+ \ }, {
+ \ "context": v:null,
+ \ "descr": "This type is incompatible with ",
+ \ "type": "Comment ",
+ \ "path": "",
+ \ "line": 0,
+ \ "endline": 0,
+ \ "start": 1,
+ \ "end": 0
+ \ }, {
+ \ "context": "setVector: VectorType => void,",
+ \ "descr": "function type ",
+ \ "type": "Blame ",
+ \ "loc": {
+ \ "source": expand('%:p'),
+ \ "type": "SourceFile",
+ \ "start": {
+ \ "line": 9,
+ \ "column": 14,
+ \ "offset": 252
+ \ },
+ \ "end": {
+ \ "line": 9,
+ \ "column": 31,
+ \ "offset": 270
+ \ }
+ \ },
+ \ "path": expand('%:p'),
+ \ "line": 9,
+ \ "endline": 9,
+ \ "start": 14,
+ \ "end": 31
+ \ }]
+ \ }]
+ \ }],
+ \ "kind": "infer",
+ \ "level": "error",
+ \ "suppressions": [],
+ \ "message": [{
+ \ "context": " < New ",
+ \ "descr": "props of React element `New`",
+ \ "type": "Blame",
+ \ "loc": {
+ \ "source": "vim-ale-flow/foo.js",
+ \ "type": "SourceFile",
+ \ "start": {
+ \ "line": 89,
+ \ "column": 17,
+ \ "offset": 2262
+ \ },
+ \ "end": {
+ \ "line": 94,
+ \ "column": 18,
+ \ "offset": 2488
+ \ }
+ \ },
+ \ "path": "",
+ \ "line": 89,
+ \ "endline": 94,
+ \ "start": 17,
+ \ "end": 18
+ \ }, {
+ \ "context": v:null,
+ \ "descr": "This type is incompatible with",
+ \ "type": "Comment",
+ \ "path": "",
+ \ "line": 0,
+ \ "endline": 0,
+ \ "start": 1,
+ \ "end": 0
+ \ }, {
+ \ "context": "class New extends React.Component < NewProps,NewState > {",
+ \ "descr": "object type",
+ \ "type": "Blame",
+ \ "loc": {
+ \ "source": expand('%:p'),
+ \ "type": "SourceFile",
+ \ "start": {
+ \ "line": 20,
+ \ "column": 35,
+ \ "offset": 489
+ \ },
+ \ "end": {
+ \ "line": 20,
+ \ "column": 42,
+ \ "offset": 497
+ \ }
+ \ },
+ \ "path": expand('%:p'),
+ \ "line": 20,
+ \ "endline": 20,
+ \ "start": 35,
+ \ "end": 42
+ \ }]
+ \ }],
+ \ "passed": v:false
+ \}
+
+ let g:actual = ale_linters#javascript#flow#Handle(bufnr(''), [json_encode(g:flow_output)])
+ let g:expected = [
+ \ {
+ \ 'lnum': 20,
+ \ 'col': 35,
+ \ 'type': 'E',
+ \ 'text': 'props of React element `New`: This type is incompatible with object type',
+ \ 'detail': 'Property `setVector` is incompatible: number This type is incompatible with function type ',
\ }
\]