Skip to content

Commit

Permalink
Add one more test for manual mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarzka committed Jan 24, 2019
1 parent f608a40 commit f05a456
Showing 1 changed file with 29 additions and 22 deletions.
51 changes: 29 additions & 22 deletions test/stylefy/tests/conversion_test.cljs
Expand Up @@ -99,25 +99,32 @@
"code{color:red}"))))

(deftest manual-mode
(let [media-query {:max-width "550px"}
style {:width "500px"
:height "200px"
:padding "33px"
:margin-bottom "10px"
:background-color "#55AA55"
::stylefy/class-prefix "seppo"
::stylefy/mode {:hover {:background-color "#99DD99"}}
::stylefy/sub-styles {:innerbox {:width "100%"
:height "100%"
:background-color "#444444"}}
::stylefy/manual [[:&:hover [:.innerbox
{:background-color "#999999"}
[:&:hover {:background-color "#EEEEEE"}]]]
(at-media media-query [:&:hover [:.innerbox
{:background-color "#666666"}
[:&:hover {:background-color "#111111"}]]])]
::stylefy/media {media-query
{:width "200px"
::stylefy/mode {:hover {:background-color "#336633"}}}}}]
(is (= (conversion/style->css {:props style :hash (styles/hash-style style)} {:pretty-print? false})
"._stylefy_640089058{background-color:#55AA55;width:500px;padding:33px;margin-bottom:10px;height:200px}._stylefy_640089058:hover{background-color:#99DD99}@media(max-width:550px){._stylefy_640089058{width:200px}._stylefy_640089058:hover{background-color:#336633}}._stylefy_640089058:hover .innerbox{background-color:#999999}._stylefy_640089058:hover .innerbox:hover{background-color:#EEEEEE}@media(max-width:550px){._stylefy_640089058:hover .innerbox{background-color:#666666}._stylefy_640089058:hover .innerbox:hover{background-color:#111111}}"))))
(testing "Simple manual mode map"
(let [style {::stylefy/manual [[:p {:color :red}]
[:main [:article [:.title {:color :black}]]]]}]
(is (= (conversion/style->css {:props style :hash (styles/hash-style style)} {:pretty-print? false})
"._stylefy_353473522{}._stylefy_353473522 p{color:red}._stylefy_353473522 main article .title{color:black}"))))

(testing "Complex manual mode selector"
(let [media-query {:max-width "550px"}
style {:width "500px"
:height "200px"
:padding "33px"
:margin-bottom "10px"
:background-color "#55AA55"
::stylefy/class-prefix "seppo"
::stylefy/mode {:hover {:background-color "#99DD99"}}
::stylefy/sub-styles {:innerbox {:width "100%"
:height "100%"
:background-color "#444444"}}
::stylefy/manual [[:&:hover [:.innerbox
{:background-color "#999999"}
[:&:hover {:background-color "#EEEEEE"}]]]
(at-media media-query [:&:hover [:.innerbox
{:background-color "#666666"}
[:&:hover {:background-color "#111111"}]]])]
::stylefy/media {media-query
{:width "200px"
::stylefy/mode {:hover {:background-color "#336633"}}}}}]
(is (= (conversion/style->css {:props style :hash (styles/hash-style style)} {:pretty-print? false})
"._stylefy_640089058{background-color:#55AA55;width:500px;padding:33px;margin-bottom:10px;height:200px}._stylefy_640089058:hover{background-color:#99DD99}@media(max-width:550px){._stylefy_640089058{width:200px}._stylefy_640089058:hover{background-color:#336633}}._stylefy_640089058:hover .innerbox{background-color:#999999}._stylefy_640089058:hover .innerbox:hover{background-color:#EEEEEE}@media(max-width:550px){._stylefy_640089058:hover .innerbox{background-color:#666666}._stylefy_640089058:hover .innerbox:hover{background-color:#111111}}")))))

0 comments on commit f05a456

Please sign in to comment.