Skip to content

Commit 83c295f

Browse files
committed
Fix tests
1 parent 7aa21e4 commit 83c295f

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

src/lambdaisland/ornament.cljc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -623,13 +623,15 @@
623623
when `*compile-files*` is true, to prevent CSS from bloating up a production
624624
build."
625625
[docstring rules]
626-
(str
627-
docstring
628-
(when (not *compile-files*)
629-
(str
630-
(when docstring
631-
(str "\n\n"))
632-
(gc/compile-css (process-rules rules)))))))
626+
(let [css (gc/compile-css (process-rules rules))]
627+
(str
628+
docstring
629+
(when (not *compile-files*)
630+
(str
631+
(when (and (not (str/blank? docstring))
632+
(not (str/blank? css)))
633+
(str "\n\n"))
634+
css))))))
633635

634636
#?(:clj
635637
(defn component->selector [&env s]

test/lambdaisland/ornament_test.cljc

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
(ns ^{:ornament/prefix "ot__"}
22
lambdaisland.ornament-test
3-
(:require [lambdaisland.ornament :as o]
4-
[clojure.test :refer [deftest testing is are use-fixtures run-tests join-fixtures]]
5-
#?(:clj [lambdaisland.hiccup :as hiccup]
6-
:cljs [lambdaisland.thicc :as thicc]))
3+
(:require
4+
[lambdaisland.ornament :as o]
5+
[clojure.string :as str]
6+
[clojure.test :refer [deftest testing is are use-fixtures run-tests join-fixtures]]
7+
#?(:clj [lambdaisland.hiccup :as hiccup]
8+
:cljs [lambdaisland.thicc :as thicc]))
79
#?(:cljs
810
(:require-macros lambdaisland.ornament-test)))
911

@@ -273,18 +275,15 @@
273275
;; conditionals.
274276
;; FIXME: write this in a more robust way, maintaining this is becoming a PITA
275277
[attrs-in-fragment "hello"]
276-
#?(:clj "<div lang=\"nl\" class=\"ot__attrs_in_fragment\">hello</div>"
277-
:cljs "<div class=\"ot__attrs_in_fragment\" lang=\"nl\">hello</div>")
278+
"<div lang=\"nl\" class=\"ot__attrs_in_fragment\">hello</div>"
278279

279280
[attrs-in-fragment-props
280281
{:person "Arne"
281282
::o/attrs {:lang "en" :title "greeting"}}]
282-
#?(:clj "<div lang=\"en\" title=\"greeting\" class=\"ot__attrs_in_fragment_props\">hello, Arne</div>"
283-
:cljs "<div title=\"greeting\" class=\"ot__attrs_in_fragment_props\" lang=\"en\">hello, Arne</div>")
283+
"<div lang=\"en\" title=\"greeting\" class=\"ot__attrs_in_fragment_props\">hello, Arne</div>"
284284

285285
[attrs-in-fragment-props {:person "Jake"}]
286-
#?(:clj "<div lang=\"nl\" class=\"ot__attrs_in_fragment_props\">hello, Jake</div>"
287-
:cljs "<div class=\"ot__attrs_in_fragment_props\" lang=\"nl\">hello, Jake</div>")
286+
"<div lang=\"nl\" class=\"ot__attrs_in_fragment_props\">hello, Jake</div>"
288287

289288
[attrs-in-fragment-styled {:person "Finn"}]
290289
"<div class=\"ot__attrs_in_fragment_styled extra-class\" style=\"color: blue;\">hello, Finn</div>"
@@ -460,14 +459,16 @@
460459

461460
(deftest docstring-test
462461
(is (= "A documented component" (:doc (meta #'with-doc))))
463-
(is (= "A documented component" (:doc (meta #'with-doc2))))
464-
(is (= "A documented component" (:doc (meta #'with-doc3))))
462+
(is (str/starts-with? (:doc (meta #'with-doc2)) "A documented component"))
463+
(is (str/starts-with? (:doc (meta #'with-doc3)) "A documented component"))
465464

466-
(is (= '([] [& children] [attrs & children])
467-
(:arglists (meta #'combined))))
465+
#?(:clj
466+
(is (= '([] [& children] [attrs & children])
467+
(:arglists (meta #'combined)))))
468468

469-
(is (= '([{:keys [date time]}])
470-
(:arglists (meta #'timed)))))
469+
#?(:clj
470+
(is (= '([{:keys [date time]}])
471+
(:arglists (meta #'timed))))))
471472

472473
(comment
473474
(require 'kaocha.repl)

0 commit comments

Comments
 (0)