summaryrefslogtreecommitdiff
path: root/test/test_hover_parsing.vader
diff options
context:
space:
mode:
authorBartek thindil Jasicki <thindil@laeran.pl>2020-08-14 19:38:09 +0200
committerBartek thindil Jasicki <thindil@laeran.pl>2020-08-14 19:38:09 +0200
commit04bd84e914af02e1c7d61ccf8f8368de85eab30e (patch)
treeda622d456ce01358a85a680f9fc8d802bc61ff01 /test/test_hover_parsing.vader
parent973c4ea053f78d4daa6eceff36da0bbecd788077 (diff)
parent5ceda0164c5fae0d61fd51d4c9e083b27abdc9d2 (diff)
downloadale-04bd84e914af02e1c7d61ccf8f8368de85eab30e.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'test/test_hover_parsing.vader')
-rw-r--r--test/test_hover_parsing.vader173
1 files changed, 173 insertions, 0 deletions
diff --git a/test/test_hover_parsing.vader b/test/test_hover_parsing.vader
new file mode 100644
index 00000000..4129c26a
--- /dev/null
+++ b/test/test_hover_parsing.vader
@@ -0,0 +1,173 @@
+Execute(Invalid results should be handled):
+ AssertEqual [[], []], ale#hover#ParseLSPResult(0)
+ AssertEqual [[], []], ale#hover#ParseLSPResult([0])
+ AssertEqual [[], []], ale#hover#ParseLSPResult('')
+ AssertEqual [[], []], ale#hover#ParseLSPResult({})
+ AssertEqual [[], []], ale#hover#ParseLSPResult([{}])
+ AssertEqual [[], []], ale#hover#ParseLSPResult([''])
+ AssertEqual [[], []], ale#hover#ParseLSPResult({'value': ''})
+ AssertEqual [[], []], ale#hover#ParseLSPResult([{'value': ''}])
+ AssertEqual [[], []], ale#hover#ParseLSPResult({'kind': 'markdown'})
+ AssertEqual [[], []], ale#hover#ParseLSPResult({'kind': 'plaintext'})
+ AssertEqual [[], []], ale#hover#ParseLSPResult({'kind': 'x', 'value': 'xxx'})
+
+Execute(A string with a code fence should be handled):
+ AssertEqual
+ \ [
+ \ [
+ \ 'unlet! b:current_syntax',
+ \ 'syntax include @ALE_hover_python syntax/python.vim',
+ \ 'syntax region ALE_hover_1 start=/\%1l/ end=/\%3l/ contains=@ALE_hover_python',
+ \ ],
+ \ [
+ \ 'def foo():',
+ \ ' pass',
+ \ ],
+ \ ],
+ \ ale#hover#ParseLSPResult(join([
+ \ '```python',
+ \ 'def foo():',
+ \ ' pass',
+ \ '```',
+ \ ], "\n"))
+
+ AssertEqual
+ \ [
+ \ [
+ \ 'unlet! b:current_syntax',
+ \ 'syntax include @ALE_hover_python syntax/python.vim',
+ \ 'unlet! b:current_syntax',
+ \ 'syntax include @ALE_hover_typescript syntax/typescript.vim',
+ \ 'syntax region ALE_hover_1 start=/\%1l/ end=/\%3l/ contains=@ALE_hover_python',
+ \ 'syntax region ALE_hover_2 start=/\%5l/ end=/\%8l/ contains=@ALE_hover_python',
+ \ 'syntax region ALE_hover_3 start=/\%8l/ end=/\%10l/ contains=@ALE_hover_typescript',
+ \ ],
+ \ [
+ \ 'def foo():',
+ \ ' pass',
+ \ '',
+ \ 'middle line',
+ \ '',
+ \ 'def bar():',
+ \ ' pass',
+ \ '',
+ \ 'const baz = () => undefined',
+ \ ],
+ \ ],
+ \ ale#hover#ParseLSPResult(join([
+ \ '```python',
+ \ 'def foo():',
+ \ ' pass',
+ \ '```',
+ \ 'middle line',
+ \ '```python',
+ \ 'def bar():',
+ \ ' pass',
+ \ '```',
+ \ '```typescript',
+ \ 'const baz = () => undefined',
+ \ '```',
+ \ ], "\n"))
+
+Execute(Multiple strings with fences should be handled):
+ AssertEqual
+ \ [
+ \ [
+ \ 'unlet! b:current_syntax',
+ \ 'syntax include @ALE_hover_python syntax/python.vim',
+ \ 'unlet! b:current_syntax',
+ \ 'syntax include @ALE_hover_typescript syntax/typescript.vim',
+ \ 'syntax region ALE_hover_1 start=/\%1l/ end=/\%3l/ contains=@ALE_hover_python',
+ \ 'syntax region ALE_hover_2 start=/\%5l/ end=/\%8l/ contains=@ALE_hover_python',
+ \ 'syntax region ALE_hover_3 start=/\%8l/ end=/\%10l/ contains=@ALE_hover_typescript',
+ \ ],
+ \ [
+ \ 'def foo():',
+ \ ' pass',
+ \ '',
+ \ 'middle line',
+ \ '',
+ \ 'def bar():',
+ \ ' pass',
+ \ '',
+ \ 'const baz = () => undefined',
+ \ ],
+ \ ],
+ \ ale#hover#ParseLSPResult([
+ \ join([
+ \ '```python',
+ \ 'def foo():',
+ \ ' pass',
+ \ '```',
+ \ ], "\n"),
+ \ join([
+ \ 'middle line',
+ \ '```python',
+ \ 'def bar():',
+ \ ' pass',
+ \ '```',
+ \ '```typescript',
+ \ 'const baz = () => undefined',
+ \ '```',
+ \ ], "\n"),
+ \ ])
+
+Execute(Objects with kinds should be handled):
+ AssertEqual
+ \ [
+ \ [
+ \ 'unlet! b:current_syntax',
+ \ 'syntax include @ALE_hover_python syntax/python.vim',
+ \ 'syntax region ALE_hover_1 start=/\%1l/ end=/\%3l/ contains=@ALE_hover_python',
+ \ ],
+ \ [
+ \ 'def foo():',
+ \ ' pass',
+ \ '',
+ \ '```typescript',
+ \ 'const baz = () => undefined',
+ \ '```',
+ \ ],
+ \ ],
+ \ ale#hover#ParseLSPResult([
+ \ {
+ \ 'kind': 'markdown',
+ \ 'value': join([
+ \ '```python',
+ \ 'def foo():',
+ \ ' pass',
+ \ '```',
+ \ ], "\n"),
+ \ },
+ \ {
+ \ 'kind': 'plaintext',
+ \ 'value': join([
+ \ '```typescript',
+ \ 'const baz = () => undefined',
+ \ '```',
+ \ ], "\n"),
+ \ },
+ \ ])
+
+Execute(Simple markdown formatting should be handled):
+ AssertEqual
+ \ [
+ \ [
+ \ 'unlet! b:current_syntax',
+ \ 'syntax include @ALE_hover_python syntax/python.vim',
+ \ 'syntax region ALE_hover_1 start=/\%1l/ end=/\%3l/ contains=@ALE_hover_python',
+ \ ],
+ \ [
+ \ 'def foo():',
+ \ ' pass',
+ \ '',
+ \ 'formatted _ line _',
+ \ ],
+ \ ],
+ \ ale#hover#ParseLSPResult(join([
+ \ '```python',
+ \ 'def foo():',
+ \ ' pass',
+ \ '```',
+ \ 'formatted \_ line \_',
+ \ ], "\n"))