[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot 815048c 3/5: Add a test for the javascript LSP se
From: |
João Távora |
Subject: |
[elpa] externals/eglot 815048c 3/5: Add a test for the javascript LSP server |
Date: |
Wed, 13 Jun 2018 13:49:10 -0400 (EDT) |
branch: externals/eglot
commit 815048c0d37fe5b66317e3b79fec49568c64ff92
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Add a test for the javascript LSP server
* eglot-tests.el (eglot--wait-for): Fix when :method is a keyword.
(javascript-basic): New test.
(rls-watches-files, rls-hover-after-edit): Update test.
(rls-rename): Don't need to sniff comms here.
---
eglot-tests.el | 60 ++++++++++++++++++++++++++++++++++++++++------------------
1 file changed, 42 insertions(+), 18 deletions(-)
diff --git a/eglot-tests.el b/eglot-tests.el
index 8238ecc..1a25371 100644
--- a/eglot-tests.el
+++ b/eglot-tests.el
@@ -158,6 +158,12 @@ Pass TIMEOUT to `eglot--with-timeout'."
(format "waiting for:\n%s"
(pp-to-string body))))
(let ((event
(cl-loop thereis (cl-loop for json in ,events-sym
+ for method = (plist-get json :method)
+ when (keywordp method)
+ do (plist-put json :method
+ (substring
+ (symbol-name method)
+ 1))
when (funcall
(eglot--lambda ,args ,@body) json)
return (cons json before)
@@ -262,7 +268,7 @@ Pass TIMEOUT to `eglot--with-timeout'."
(eglot--wait-for
(c-notifs 3 "waiting for didChangeWatchedFiles notification")
(&key method params &allow-other-keys)
- (and (eq method :workspace/didChangeWatchedFiles)
+ (and (string= method "workspace/didChangeWatchedFiles")
(cl-destructuring-bind (&key uri type)
(elt (plist-get params :changes) 0)
(and (string= (eglot--path-to-uri "Cargo.toml") uri)
@@ -302,11 +308,7 @@ Pass TIMEOUT to `eglot--with-timeout'."
(eglot--find-file-noselect "hover-project/main.rs")
(should (zerop (shell-command "cargo init")))
(eglot--sniffing (
- :server-notifications s-notifs
- :server-requests s-requests
:server-replies s-replies
- :client-notifications c-notifs
- :client-replies c-replies
:client-requests c-reqs
)
(eglot--tests-connect)
@@ -322,7 +324,7 @@ Pass TIMEOUT to `eglot--with-timeout'."
(eglot--wait-for (c-reqs)
(&key id method &allow-other-keys)
(setq pending-id id)
- (string= method :textDocument/documentHighlight))
+ (string= method "textDocument/documentHighlight"))
(eglot--wait-for (s-replies)
(&key id &allow-other-keys)
(eq id pending-id))))))))
@@ -339,18 +341,10 @@ Pass TIMEOUT to `eglot--with-timeout'."
(with-current-buffer
(eglot--find-file-noselect "rename-project/main.rs")
(should (zerop (shell-command "cargo init")))
- (eglot--sniffing (
- :server-notifications s-notifs
- :server-requests s-requests
- :server-replies s-replies
- :client-notifications c-notifs
- :client-replies c-replies
- :client-requests c-reqs
- )
- (eglot--tests-connect)
- (goto-char (point-min)) (search-forward "return te")
- (eglot-rename "bla")
- (should (equal (buffer-string) "fn test() -> i32 { let bla=3; return
bla; }")))))))
+ (eglot--tests-connect)
+ (goto-char (point-min)) (search-forward "return te")
+ (eglot-rename "bla")
+ (should (equal (buffer-string) "fn test() -> i32 { let bla=3; return
bla; }"))))))
(ert-deftest basic-completions ()
"Test basic autocompletion in a python LSP"
@@ -381,6 +375,36 @@ Pass TIMEOUT to `eglot--with-timeout'."
(while (not eldoc-last-message) (accept-process-output nil 0.1))
(should (string-match "^exit" eldoc-last-message))))))
+(ert-deftest javascript-basic ()
+ "Test basic autocompletion in a python LSP"
+ (skip-unless (executable-find "~/.yarn/bin/javascript-typescript-stdio"))
+ (eglot--with-dirs-and-files
+ '(("project" . (("hello.js" . "console.log('Hello world!');"))))
+ (eglot--with-timeout 4
+ (with-current-buffer
+ (eglot--find-file-noselect "project/hello.js")
+ (let ((eglot-server-programs
+ '((js-mode . ("~/.yarn/bin/javascript-typescript-stdio")))))
+ (goto-char (point-max))
+ (eglot--sniffing (:server-notifications
+ s-notifs
+ :client-notifications
+ c-notifs)
+ (should (eglot--tests-connect))
+ (eglot--wait-for (s-notifs 1) (&key method &allow-other-keys)
+ (string= method "textDocument/publishDiagnostics"))
+ (should (not (eq 'flymake-error (face-at-point))))
+ (insert "{")
+ (eglot--signal-textDocument/didChange)
+ (eglot--wait-for (c-notifs 1) (&key method &allow-other-keys)
+ (string= method "textDocument/didChange"))
+ (eglot--wait-for (s-notifs 1) (&key params method
&allow-other-keys)
+ (and (string= method "textDocument/publishDiagnostics")
+ (cl-destructuring-bind (&key _uri diagnostics) params
+ (cl-find-if (eglot--lambda (&key severity
&allow-other-keys)
+ (= severity 1))
+ diagnostics))))))))))
+
(provide 'eglot-tests)
;;; eglot-tests.el ends here