Skip to content

Commit

Permalink
Test display of code lens
Browse files Browse the repository at this point in the history
  • Loading branch information
necto committed Jul 21, 2024
1 parent e9a84f4 commit c6f29cb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
19 changes: 19 additions & 0 deletions test/lsp-mock-server-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -835,4 +835,23 @@ line 3 words here and here
(should (equal (line-number-at-pos) (1+ hint-line)))
(should (equal (current-column) hint-col))))))))

(ert-deftest lsp-test-server-provides-code-lens ()
"lsp-mode accepts code lenses from the server and displays them."
(let ((line 2))
(lsp-test-schedule-response
"textDocument/codeLens"
(vconcat (list `(:range (:start (:line ,line :character 0)
:end (:line ,line :character 1))
:command (:title "My command"
:command "myCommand")))))
(lsp-mock-run-with-mock-server
(lsp-test-sync-wait (lsp-test-all-overlays 'lsp-lens))
(let ((lenses (lsp-test-all-overlays 'lsp-lens)))
(should (eq (length lenses) 1))
(message "%s" (overlay-properties (car lenses)))
(should (string-match-p "My command"
(overlay-get (car lenses) 'after-string)))
(goto-char (overlay-start (car lenses)))
(should (equal (line-number-at-pos) (- line 1)))))))

;;; lsp-mock-server-test.el ends here
3 changes: 2 additions & 1 deletion test/mock-lsp-server.el
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
:codeActionProvider t
:declarationProvider t
:definitionProvider t
:inlayHintProvider t)
:inlayHintProvider t
:codeLensProvider (:resolveProvider ()))
"Capabilities of the server.")

(defun greeting (id)
Expand Down

0 comments on commit c6f29cb

Please sign in to comment.