Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zampino committed Nov 21, 2023
1 parent b681d57 commit df5f555
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions test/nextjournal/clerk/eval_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@
eval/eval-string
view/doc->viewer
:nextjournal/value
:blocks))
:blocks
;; remove hidden results
(->> (remove (comp #{:hide} :result :nextjournal/visibility :nextjournal/presented :nextjournal/value)))))

(deftest eval-string+doc->viewer
(testing "assigns correct width from viewer function opts"
Expand Down Expand Up @@ -240,4 +242,3 @@
(catch Exception _ nil))
(clerk/show! (java.io.StringReader. code))
(is (= result-first-run (get-result)))))))

12 changes: 6 additions & 6 deletions test/nextjournal/clerk/viewer_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
(deftest default-viewers
(testing "viewers have names matching vars"
(doseq [[viewer-name viewer] (into {}
(map (juxt :name (comp deref resolve :name)))
(map (juxt :name (comp deref resolve :name)))
v/default-viewers)]
(is (= viewer-name (:name viewer))))))

Expand Down Expand Up @@ -307,22 +307,22 @@
(testing "Settings propagation from ns to form"
(is (= :full
(-> (eval/eval-string "(ns nextjournal.clerk.viewer-test.settings {:nextjournal.clerk/width :full}) (nextjournal.clerk/html [:div])")
view/doc->viewer v/->value :blocks (nth 2)
view/doc->viewer v/->value :blocks (nth 3)
v/->value :nextjournal/presented :nextjournal/width)))

(is (= :wide
(-> (eval/eval-string "(ns nextjournal.clerk.viewer-test.settings {:nextjournal.clerk/width :full}) (nextjournal.clerk/html {:nextjournal.clerk/width :wide} [:div])")
view/doc->viewer v/->value :blocks (nth 2)
view/doc->viewer v/->value :blocks (nth 3)
v/->value :nextjournal/presented :nextjournal/width)))

(is (= :wide
(-> (eval/eval-string "(ns nextjournal.clerk.viewer-test.settings {:nextjournal.clerk/width :full}) ^{:nextjournal.clerk/width :wide} (nextjournal.clerk/html [:div])")
view/doc->viewer v/->value :blocks (nth 2)
view/doc->viewer v/->value :blocks (nth 3)
v/->value :nextjournal/presented :nextjournal/width)))

(is (= :wide
(-> (eval/eval-string "(ns nextjournal.clerk.viewer-test.settings {:nextjournal.clerk/width :full}) {:nextjournal.clerk/width :wide} (nextjournal.clerk/html [:div])")
view/doc->viewer v/->value :blocks (nth 2)
view/doc->viewer v/->value :blocks (nth 4)
v/->value :nextjournal/presented :nextjournal/width))))

(testing "Presented doc (with fragments) has unambiguous ids assigned to results"
Expand Down Expand Up @@ -397,7 +397,7 @@
(is (= "(do 'this)"
(-> (eval/eval-string "(ns test.removed-metadata\n(:require [nextjournal.clerk :as c]))\n\n^::c/no-cache (do 'this)")
view/doc->viewer
v/->value :blocks second v/->value))))
v/->value :blocks (nth 2) v/->value))))

(deftest col-viewer-map-args
(testing "extracts first arg as viewer-opts"
Expand Down

0 comments on commit df5f555

Please sign in to comment.