summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-02-10 22:47:56 +0000
committerw0rp <devw0rp@gmail.com>2017-02-10 22:47:56 +0000
commit49f7ce4f6dbca39a013be6d5714d11a2b882d17c (patch)
tree7a2335cc70bb7879c9ae4e54a810162ed7ef0dc1 /test
parent926cd1a9533a816b0dbd7f6ca2ccbd2cd9cc2399 (diff)
downloadale-49f7ce4f6dbca39a013be6d5714d11a2b882d17c.zip
Fix #246 Don't run flow if there's no .flowconfig
Diffstat (limited to 'test')
-rw-r--r--test/flow/a/.flowconfig0
-rw-r--r--test/flow/a/sub/dummy0
-rw-r--r--test/flow/b/sub/dummy0
-rw-r--r--test/test_flow_command.vader17
-rw-r--r--test/test_flow_handler.vader132
5 files changed, 149 insertions, 0 deletions
diff --git a/test/flow/a/.flowconfig b/test/flow/a/.flowconfig
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/flow/a/.flowconfig
diff --git a/test/flow/a/sub/dummy b/test/flow/a/sub/dummy
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/flow/a/sub/dummy
diff --git a/test/flow/b/sub/dummy b/test/flow/b/sub/dummy
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/flow/b/sub/dummy
diff --git a/test/test_flow_command.vader b/test/test_flow_command.vader
new file mode 100644
index 00000000..00a2c2a7
--- /dev/null
+++ b/test/test_flow_command.vader
@@ -0,0 +1,17 @@
+Before:
+ runtime ale_linters/javascript/flow.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(flow should return a command to run if a .flowconfig file exists):
+ silent! cd /testplugin/test
+ :e! flow/a/sub/dummy
+
+ AssertEqual 'flow check-contents --respect-pragma --json --from ale %s', ale_linters#javascript#flow#GetCommand(bufnr('%'))
+
+Execute(flow should not return a command to run if no .flowconfig file exists):
+ silent! cd /testplugin/test
+ :e! flow/b/sub/dummy
+
+ AssertEqual '', ale_linters#javascript#flow#GetCommand(bufnr('%'))
diff --git a/test/test_flow_handler.vader b/test/test_flow_handler.vader
new file mode 100644
index 00000000..12fe0891
--- /dev/null
+++ b/test/test_flow_handler.vader
@@ -0,0 +1,132 @@
+Before:
+ let g:flow_output = {
+ \ "flowVersion": "0.39.0",
+ \ "errors": [
+ \ {
+ \ "kind": "infer",
+ \ "level": "error",
+ \ "message": [
+ \ {
+ \ "context": " return 1",
+ \ "descr": "number",
+ \ "type": "Blame",
+ \ "loc": {
+ \ "source": "/home/w0rp/Downloads/graphql-js/src/language/parser.js",
+ \ "type": "SourceFile",
+ \ "start": {
+ \ "line": 417,
+ \ "column": 10,
+ \ "offset": 9503
+ \ },
+ \ "end": {
+ \ "line": 417,
+ \ "column": 10,
+ \ "offset": 9504
+ \ }
+ \ },
+ \ "path": "/home/w0rp/Downloads/graphql-js/src/language/parser.js",
+ \ "line": 417,
+ \ "endline": 417,
+ \ "start": 10,
+ \ "end": 10
+ \ },
+ \ {
+ \ "context": v:null,
+ \ "descr": "This type is incompatible with the expected return type of",
+ \ "type": "Comment",
+ \ "path": "",
+ \ "line": 0,
+ \ "endline": 0,
+ \ "start": 1,
+ \ "end": 0
+ \ },
+ \ {
+ \ "context": "function parseArguments(lexer: Lexer<*>): Array<ArgumentNode> {",
+ \ "descr": "array type",
+ \ "type": "Blame",
+ \ "loc": {
+ \ "source": "/home/w0rp/Downloads/graphql-js/src/language/parser.js",
+ \ "type": "SourceFile",
+ \ "start": {
+ \ "line": 416,
+ \ "column": 43,
+ \ "offset": 9472
+ \ },
+ \ "end": {
+ \ "line": 416,
+ \ "column": 61,
+ \ "offset": 9491
+ \ }
+ \ },
+ \ "path": "/home/w0rp/Downloads/graphql-js/src/language/parser.js",
+ \ "line": 416,
+ \ "endline": 416,
+ \ "start": 43,
+ \ "end": 61
+ \ }
+ \ ]
+ \ },
+ \ {
+ \ "kind": "infer",
+ \ "level": "warning",
+ \ "message": [
+ \ {
+ \ "context": " return peek(lexer, TokenKind.PAREN_L) ?",
+ \ "descr": "unreachable code",
+ \ "type": "Blame",
+ \ "loc": {
+ \ "source": "/home/w0rp/Downloads/graphql-js/src/language/parser.js",
+ \ "type": "SourceFile",
+ \ "start": {
+ \ "line": 419,
+ \ "column": 3,
+ \ "offset": 9508
+ \ },
+ \ "end": {
+ \ "line": 421,
+ \ "column": 7,
+ \ "offset": 9626
+ \ }
+ \ },
+ \ "path": "/home/w0rp/Downloads/graphql-js/src/language/parser.js",
+ \ "line": 419,
+ \ "endline": 421,
+ \ "start": 3,
+ \ "end": 7
+ \ }
+ \ ]
+ \ }
+ \ ],
+ \ "passed": v:false
+ \}
+
+ runtime ale_linters/javascript/flow.vim
+
+After:
+ unlet! g:flow_output
+ unlet! g:expected
+ unlet! g:actual
+ call ale#linter#Reset()
+
+Execute(The flow handler should process errors correctly.):
+ let g:actual = ale_linters#javascript#flow#Handle(347, [json_encode(g:flow_output)])
+ let g:expected = [
+ \ {
+ \ 'lnum': 417,
+ \ 'bufnr': 347,
+ \ 'vcol': 0,
+ \ 'type': 'E',
+ \ 'col': 10,
+ \ 'text': 'number: This type is incompatible with the expected return type of array type',
+ \ },
+ \ {
+ \ 'lnum': 419,
+ \ 'bufnr': 347,
+ \ 'vcol': 0,
+ \ 'type': 'W',
+ \ 'col': 3,
+ \ 'text': 'unreachable code:',
+ \ },
+ \]
+
+ AssertEqual g:expected, g:actual