Skip to content

Commit

Permalink
Tabular testing
Browse files Browse the repository at this point in the history
  • Loading branch information
raxod502 committed Mar 13, 2024
1 parent b9ebda0 commit f581675
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions test/unit/apheleia-unit.el
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,27 @@

(require 'ert)

(defun apheleia-unit-find-vars (form)
(cond
((symbolp form)
(list form))
((listp form)
(mapcan #'apheleia-unit-find-vars (cdr form)))))

(ert-deftest apheleia-align-point ()
;; https://github.com/radian-software/apheleia/pull/290
(should
(equal
(apheleia--align-point
" <div class=\"left-[40rem] fixed inset-y-0 right-0 z-0 hidden lg:block xl:left-[50rem]\">\n <svg\n"
"<div class=\"left-[40rem] fixed inset-y-0 right-0 z-0 hidden lg:block xl:left-[50rem]\">\n <svg"
6)
1)))
(dolist (testcase
'(("hello| world"
"helo| word")
("hello | world"
"hello|world")
;; https://github.com/radian-software/apheleia/pull/290
(" | <div class=\"left-[40rem] fixed inset-y-0 right-0 z-0 hidden lg:block xl:left-[50rem]\">\n <svg\n"
"<|div class=\"left-[40rem] fixed inset-y-0 right-0 z-0 hidden lg:block xl:left-[50rem]\">\n <svg")))
(save-match-data
(cl-destructuring-bind (before-spec after-spec) testcase
(let ((before-pos (string-match "|" before-spec))
(after-pos (string-match "|" after-spec))
(before-str (replace-regexp-in-string "|" "" before-spec))
(after-str (replace-regexp-in-string "|" "" after-spec)))
(should
(equal (apheleia--align-point before-str after-str before-pos) after-pos)))))))

0 comments on commit f581675

Please sign in to comment.