Skip to content

Commit

Permalink
Add a second statement to our defkeyframes test subject
Browse files Browse the repository at this point in the history
Most of the changes here are indents from using clojure-lsp
  • Loading branch information
dhleong committed Nov 1, 2024
1 parent 08356dc commit a247c58
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions test/spade/core_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,24 @@
:css
(str/replace #"\s+" " "))]
(is (str/includes?
generated
(str "@media (max-width: 50px) { "
".with-media { background: blue; } "
".with-media .nested { background: red; }")))))
generated
(str "@media (max-width: 50px) { "
".with-media { background: blue; } "
".with-media .nested { background: red; }")))))

(testing "CSS var declaration and usage"
(let [generated (-> (class-with-vars-factory$ "class-with-vars" [])
:css
(str/replace #"\s+" " "))]
(is (str/includes?
generated
(str ".class-with-vars {"
" --my-var: 42pt;"
" --spade-core-test--namespaced: blue;"
" font-size: var(--my-var);"
" background: var(--spade-core-test--namespaced);"
" color: var(--my-var) !important;"
" }"))))))

generated
(str ".class-with-vars {"
" --my-var: 42pt;"
" --spade-core-test--namespaced: blue;"
" font-size: var(--my-var);"
" background: var(--spade-core-test--namespaced);"
" color: var(--my-var) !important;"
" }"))))))

(defattrs fixed-style-attrs []
{:*my-var* "blue"
Expand All @@ -90,12 +89,11 @@
:css
(str/replace #"\s+" " "))]
(is (str/includes?
generated
(str ".with-vars {"
" --my-var: blue;"
" color: var(--my-var);"
" }"))))))

generated
(str ".with-vars {"
" --my-var: blue;"
" color: var(--my-var);"
" }"))))))

(defglobal global-1
[":root" {:*background* "blue"}]
Expand All @@ -114,16 +112,16 @@

(testing "Support at-media automatically"
(is (str/starts-with?
global-2
"@media (min-width: 42px) {"))))

global-2
"@media (min-width: 42px) {"))))

(defkeyframes key-frames []
[:from {:opacity 0}])

(defkeyframes parameterized-key-frames [from]
[:from {::*from* from
:opacity ::*from*}])
:opacity ::*from*}]
[:to {:opacity 1}])

(deftest defkeyframes-test
(testing "Return keyframes name from defkeyframes"
Expand All @@ -138,15 +136,18 @@

(testing "CSS var declaration and usage"
(let [generated (-> (parameterized-key-frames-factory$
"with-vars" [42])
"with-vars" [42])
:css
(str/replace #"\s+" " "))]
(is (str/includes?
generated
(str "from {"
" --spade-core-test--from: 42;"
" opacity: var(--spade-core-test--from);"
" }"))))))
generated
(str "from {"
" --spade-core-test--from: 42;"
" opacity: var(--spade-core-test--from);"
" }")))
(is (str/includes?
generated
(str "to { opacity: 1; }"))))))

(defclass composed [color]
^{:key color}
Expand Down Expand Up @@ -186,13 +187,12 @@

(let [generated (:css (composed-list-factory$ "" ["blue"]))]
(is (false? (str/includes? generated
"color:")))
"color:")))
(is (false? (str/includes? generated
"composes:")))
"composes:")))
(is (true? (str/includes? generated
"background:"))))))


(defattrs composed-attrs [color]
^{:key color}
{:composes (computed-key color)
Expand Down

0 comments on commit a247c58

Please sign in to comment.