forked from microsoft/multilspy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_sync_multilspy_javascript.py
49 lines (42 loc) · 1.99 KB
/
test_sync_multilspy_javascript.py
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
"""
This file contains tests for running the JavaScript Language Server: typescript-language-server
"""
from multilspy import SyncLanguageServer
from multilspy.multilspy_config import Language
from tests.test_utils import create_test_context
from pathlib import PurePath
def test_sync_multilspy_javascript_exceljs() -> None:
"""
Test the working of multilspy with javascript repository - exceljs
"""
code_language = Language.JAVASCRIPT
params = {
"code_language": code_language,
"repo_url": "https://github.com/exceljs/exceljs/",
"repo_commit": "ac96f9a61e9799c7776bd940f05c4a51d7200209"
}
with create_test_context(params) as context:
lsp = SyncLanguageServer.create(context.config, context.logger, context.source_directory)
# All the communication with the language server must be performed inside the context manager
# The server process is started when the context manager is entered and is terminated when the context manager is exited.
with lsp.start_server():
path = str(PurePath("lib/csv/csv.js"))
result = lsp.request_definition(path, 108, 3)
assert isinstance(result, list)
assert len(result) == 1
item = result[0]
assert item["relativePath"] == path
assert item["range"] == {
"start": {"line": 108, "character": 2},
"end": {"line": 108, "character": 7},
}
result = lsp.request_references(path, 108, 3)
assert isinstance(result, list)
assert len(result) == 2
for item in result:
del item["uri"]
del item["absolutePath"]
assert result == [
{'range': {'start': {'line': 180, 'character': 16}, 'end': {'line': 180, 'character': 21}}, 'relativePath': path},
{'range': {'start': {'line': 185, 'character': 15}, 'end': {'line': 185, 'character': 20}}, 'relativePath': path}
]