Skip to content

Commit b24c30d

Browse files
committed
simplify test
1 parent 96f0dc7 commit b24c30d

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

test/nextjournal/clerk/viewer_test.clj

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -216,30 +216,29 @@
216216

217217
(def apply+get-value #(-> % v/apply-viewer-unwrapping-var-from-def :nextjournal/value :nextjournal/value))
218218
(deftest apply-viewer-unwrapping-var-from-def
219-
(let [apply+get-value #(-> % v/apply-viewer-unwrapping-var-from-def :nextjournal/value :nextjournal/value)]
220-
(testing "unwraps var when viewer doens't opt out"
221-
(is (= my-test-var
222-
(apply+get-value {:nextjournal/value [:h1 "hi"] :nextjournal/viewer v/html})
223-
(apply+get-value {:nextjournal/value {:nextjournal.clerk/var-from-def #'my-test-var} :nextjournal/viewer v/html})
224-
(apply+get-value {:nextjournal/value {:nextjournal.clerk/var-from-def #'my-test-var} :nextjournal/viewer v/html-viewer}))))
225-
226-
(testing "leaves var wrapped when viewer opts out"
227-
(is (= {:nextjournal.clerk/var-from-def #'my-test-var}
228-
(apply+get-value {:nextjournal/value {:nextjournal.clerk/var-from-def #'my-test-var}
229-
:nextjournal/viewer (assoc v/html-viewer :var-from-def? true)}))))
230-
231-
(testing "function viewer with var-from-def"
232-
(is (= [{:nextjournal.clerk/var-from-def #'nextjournal.clerk.viewer-test/my-test-var2, :nextjournal.clerk/var-snapshot 1}]
233-
(apply+get-value {:nextjournal/value {:nextjournal.clerk/var-from-def #'my-test-var2
234-
:nextjournal.clerk/var-snapshot 1}
235-
:nextjournal/viewer v/row}))))
236-
(testing "function viewer that preserves var-from-def"
237-
(let [viewer-fn (fn [v] (v/with-viewer (assoc v/html-viewer :var-from-def? true) v))]
238-
(is (= {:nextjournal.clerk/var-from-def #'my-test-var
239-
:nextjournal.clerk/var-snapshot [:h1 "hi"]}
240-
(apply+get-value {:nextjournal/value {:nextjournal.clerk/var-from-def #'my-test-var
241-
:nextjournal.clerk/var-snapshot [:h1 "hi"]}
242-
:nextjournal/viewer viewer-fn})))))))
219+
(testing "unwraps var when viewer doens't opt out"
220+
(is (= my-test-var
221+
(apply+get-value {:nextjournal/value [:h1 "hi"] :nextjournal/viewer v/html})
222+
(apply+get-value {:nextjournal/value {:nextjournal.clerk/var-from-def #'my-test-var} :nextjournal/viewer v/html})
223+
(apply+get-value {:nextjournal/value {:nextjournal.clerk/var-from-def #'my-test-var} :nextjournal/viewer v/html-viewer}))))
224+
225+
(testing "leaves var wrapped when viewer opts out"
226+
(is (= {:nextjournal.clerk/var-from-def #'my-test-var}
227+
(apply+get-value {:nextjournal/value {:nextjournal.clerk/var-from-def #'my-test-var}
228+
:nextjournal/viewer (assoc v/html-viewer :var-from-def? true)}))))
229+
230+
(testing "function viewer with var-from-def"
231+
(is (= [{:nextjournal.clerk/var-from-def #'nextjournal.clerk.viewer-test/my-test-var2, :nextjournal.clerk/var-snapshot 1}]
232+
(apply+get-value {:nextjournal/value {:nextjournal.clerk/var-from-def #'my-test-var2
233+
:nextjournal.clerk/var-snapshot 1}
234+
:nextjournal/viewer v/row}))))
235+
(testing "function viewer that preserves var-from-def"
236+
(let [viewer-fn (fn [v] (v/with-viewer (assoc v/html-viewer :var-from-def? true) v))]
237+
(is (= {:nextjournal.clerk/var-from-def #'my-test-var
238+
:nextjournal.clerk/var-snapshot [:h1 "hi"]}
239+
(apply+get-value {:nextjournal/value {:nextjournal.clerk/var-from-def #'my-test-var
240+
:nextjournal.clerk/var-snapshot [:h1 "hi"]}
241+
:nextjournal/viewer viewer-fn}))))))
243242

244243
(deftest resolve-aliases
245244
(testing "it resolves aliases"

0 commit comments

Comments
 (0)