|
39 | 39 | (original (with-temp-buffer |
40 | 40 | (insert-file-contents file) |
41 | 41 | (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)))) |
42 | 53 | (with-temp-buffer |
43 | 54 | (insert original) |
44 | 55 | (clojure-ts-mode) |
|
73 | 84 | (expect (get-text-property (match-beginning 0) 'face) |
74 | 85 | :to-equal 'font-lock-comment-face)))) |
75 | 86 |
|
| 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 | + |
76 | 115 | (it "applies expected font-lock faces to test.clj" |
77 | 116 | (let ((file (clojure-ts-test--resource-file "test.clj"))) |
78 | 117 | (with-temp-buffer |
|
111 | 150 | ;; Should find the namespace |
112 | 151 | (expect (assoc "Namespace:refactoring" flatten-index) :not :to-be nil)))))) |
113 | 152 |
|
| 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 | + |
114 | 173 | ;;; clojure-ts-mode-integration-test.el ends here |
0 commit comments