Skip to content

Commit 34912cd

Browse files
committed
Add integration tests for sample files, remove unused ones
Add integration tests for previously unused sample files: - docstrings.clj: font-lock spot checks on ns, def, defmacro, and defprotocol method docstrings - outline.clj: outline heading navigation and indentation preservation Remove sample files whose scenarios are already covered by existing specs: bug43.clj, extra_def_forms.clj, navigation.clj, regex.clj, spec.clj. Keep embed.cljs and native.jank as manual testing fixtures (they depend on optional grammars not available in CI).
1 parent de87501 commit 34912cd

6 files changed

Lines changed: 59 additions & 41 deletions

File tree

test/clojure-ts-mode-integration-test.el

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@
3939
(original (with-temp-buffer
4040
(insert-file-contents file)
4141
(buffer-string))))
42+
(with-temp-buffer
43+
(insert original)
44+
(clojure-ts-mode)
45+
(indent-region (point-min) (point-max))
46+
(expect (buffer-string) :to-equal original))))
47+
48+
(it "preserves correct indentation of outline.clj after indent-region"
49+
(let* ((file (clojure-ts-test--resource-file "outline.clj"))
50+
(original (with-temp-buffer
51+
(insert-file-contents file)
52+
(buffer-string))))
4253
(with-temp-buffer
4354
(insert original)
4455
(clojure-ts-mode)
@@ -73,6 +84,34 @@
7384
(expect (get-text-property (match-beginning 0) 'face)
7485
:to-equal 'font-lock-comment-face))))
7586

87+
(it "applies expected font-lock faces to docstrings.clj"
88+
(let ((file (clojure-ts-test--resource-file "docstrings.clj")))
89+
(with-temp-buffer
90+
(insert-file-contents file)
91+
(let ((treesit-font-lock-level 3))
92+
(clojure-ts-mode))
93+
(font-lock-ensure)
94+
;; ns docstring
95+
(goto-char (point-min))
96+
(search-forward "This is a namespace")
97+
(expect (get-text-property (match-beginning 0) 'face)
98+
:to-equal 'font-lock-doc-face)
99+
;; def with docstring before value
100+
(goto-char (point-min))
101+
(search-forward "I'm a docstring")
102+
(expect (get-text-property (match-beginning 0) 'face)
103+
:to-equal 'font-lock-doc-face)
104+
;; defmacro docstring
105+
(goto-char (point-min))
106+
(search-forward "Fixes most known bugs")
107+
(expect (get-text-property (match-beginning 0) 'face)
108+
:to-equal 'font-lock-doc-face)
109+
;; defprotocol method docstring
110+
(goto-char (point-min))
111+
(search-forward "Does foo")
112+
(expect (get-text-property (match-beginning 0) 'face)
113+
:to-equal 'font-lock-doc-face))))
114+
76115
(it "applies expected font-lock faces to test.clj"
77116
(let ((file (clojure-ts-test--resource-file "test.clj")))
78117
(with-temp-buffer
@@ -111,4 +150,24 @@
111150
;; Should find the namespace
112151
(expect (assoc "Namespace:refactoring" flatten-index) :not :to-be nil))))))
113152

153+
(describe "integration: outline on sample files"
154+
(before-all
155+
(unless (treesit-language-available-p 'clojure)
156+
(signal 'buttercup-pending "tree-sitter Clojure grammar not available")))
157+
158+
(it "navigates headings in outline.clj"
159+
(let ((file (clojure-ts-test--resource-file "outline.clj")))
160+
(with-temp-buffer
161+
(insert-file-contents file)
162+
(let ((clojure-ts-outline-variant 'comments))
163+
(clojure-ts-mode))
164+
(outline-minor-mode 1)
165+
(goto-char (point-min))
166+
(outline-next-heading)
167+
(expect (looking-at ";;; First heading") :to-be-truthy)
168+
(outline-next-heading)
169+
(expect (looking-at ";;;; Heading level 2") :to-be-truthy)
170+
(outline-next-heading)
171+
(expect (looking-at ";;; Second heading") :to-be-truthy)))))
172+
114173
;;; clojure-ts-mode-integration-test.el ends here

test/samples/bug43.clj

Lines changed: 0 additions & 7 deletions
This file was deleted.

test/samples/extra_def_forms.clj

Lines changed: 0 additions & 6 deletions
This file was deleted.

test/samples/navigation.clj

Lines changed: 0 additions & 14 deletions
This file was deleted.

test/samples/regex.clj

Lines changed: 0 additions & 7 deletions
This file was deleted.

test/samples/spec.clj

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)