Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions test/clojure-ts-mode-integration-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@
(original (with-temp-buffer
(insert-file-contents file)
(buffer-string))))
(with-temp-buffer
(insert original)
(clojure-ts-mode)
(indent-region (point-min) (point-max))
(expect (buffer-string) :to-equal original))))

(it "preserves correct indentation of outline.clj after indent-region"
(let* ((file (clojure-ts-test--resource-file "outline.clj"))
(original (with-temp-buffer
(insert-file-contents file)
(buffer-string))))
(with-temp-buffer
(insert original)
(clojure-ts-mode)
Expand Down Expand Up @@ -73,6 +84,34 @@
(expect (get-text-property (match-beginning 0) 'face)
:to-equal 'font-lock-comment-face))))

(it "applies expected font-lock faces to docstrings.clj"
(let ((file (clojure-ts-test--resource-file "docstrings.clj")))
(with-temp-buffer
(insert-file-contents file)
(let ((treesit-font-lock-level 3))
(clojure-ts-mode))
(font-lock-ensure)
;; ns docstring
(goto-char (point-min))
(search-forward "This is a namespace")
(expect (get-text-property (match-beginning 0) 'face)
:to-equal 'font-lock-doc-face)
;; def with docstring before value
(goto-char (point-min))
(search-forward "I'm a docstring")
(expect (get-text-property (match-beginning 0) 'face)
:to-equal 'font-lock-doc-face)
;; defmacro docstring
(goto-char (point-min))
(search-forward "Fixes most known bugs")
(expect (get-text-property (match-beginning 0) 'face)
:to-equal 'font-lock-doc-face)
;; defprotocol method docstring
(goto-char (point-min))
(search-forward "Does foo")
(expect (get-text-property (match-beginning 0) 'face)
:to-equal 'font-lock-doc-face))))

(it "applies expected font-lock faces to test.clj"
(let ((file (clojure-ts-test--resource-file "test.clj")))
(with-temp-buffer
Expand Down Expand Up @@ -111,4 +150,24 @@
;; Should find the namespace
(expect (assoc "Namespace:refactoring" flatten-index) :not :to-be nil))))))

(describe "integration: outline on sample files"
(before-all
(unless (treesit-language-available-p 'clojure)
(signal 'buttercup-pending "tree-sitter Clojure grammar not available")))

(it "navigates headings in outline.clj"
(let ((file (clojure-ts-test--resource-file "outline.clj")))
(with-temp-buffer
(insert-file-contents file)
(let ((clojure-ts-outline-variant 'comments))
(clojure-ts-mode))
(outline-minor-mode 1)
(goto-char (point-min))
(outline-next-heading)
(expect (looking-at ";;; First heading") :to-be-truthy)
(outline-next-heading)
(expect (looking-at ";;;; Heading level 2") :to-be-truthy)
(outline-next-heading)
(expect (looking-at ";;; Second heading") :to-be-truthy)))))

;;; clojure-ts-mode-integration-test.el ends here
7 changes: 0 additions & 7 deletions test/samples/bug43.clj

This file was deleted.

6 changes: 0 additions & 6 deletions test/samples/extra_def_forms.clj

This file was deleted.

14 changes: 0 additions & 14 deletions test/samples/navigation.clj

This file was deleted.

7 changes: 0 additions & 7 deletions test/samples/regex.clj

This file was deleted.

7 changes: 0 additions & 7 deletions test/samples/spec.clj

This file was deleted.

Loading