diff --git a/src/reagent/impl/template.cljs b/src/reagent/impl/template.cljs index 02e61aa..73cebef 100644 --- a/src/reagent/impl/template.cljs +++ b/src/reagent/impl/template.cljs @@ -82,7 +82,7 @@ (if (named? k) (if-some [k' (cache-get custom-prop-name-cache (name k))] k' - (aset prop-name-cache (name k) + (aset custom-prop-name-cache (name k) (util/dash-to-camel k))) k)) diff --git a/test/reagent/impl/template_test.cljs b/test/reagent/impl/template_test.cljs new file mode 100644 index 0000000..92d51f0 --- /dev/null +++ b/test/reagent/impl/template_test.cljs @@ -0,0 +1,20 @@ +(ns reagent.impl.template-test + (:require [clojure.test :as t :refer [deftest is testing]] + [reagent.impl.template :as tmpl] + [goog.object :as gobj])) + +(deftest cached-prop-name + (is (= "className" + (tmpl/cached-prop-name :class)))) + +(deftest cached-custom-prop-name + (is (= "class" + (tmpl/cached-custom-prop-name :class)))) + +(deftest convert-props-test + (is (gobj/equals #js {:className "a"} + (tmpl/convert-props {:class "a"} #js {:id nil :custom false}))) + (is (gobj/equals #js {:class "a"} + (tmpl/convert-props {:class "a"} #js {:id nil :custom true}))) + (is (gobj/equals #js {:className "a b" :id "a"} + (tmpl/convert-props {:class "b"} #js {:id "a" :class "a" :custom false})))) diff --git a/test/reagenttest/runtests.cljs b/test/reagenttest/runtests.cljs index 92e087a..b32d68a 100644 --- a/test/reagenttest/runtests.cljs +++ b/test/reagenttest/runtests.cljs @@ -7,6 +7,7 @@ [reagenttest.testtrack] [reagenttest.testwithlet] [reagenttest.testwrap] + [reagent.impl.template-test] [cljs.test :as test] [doo.runner :as doo :include-macros true] [reagent.core :as r] @@ -21,8 +22,7 @@ :color :#aaa}) (defn all-tests [] - #_(test/run-tests 'reagenttest.testratomasync) - (test/run-all-tests #"reagenttest.test.*")) + (test/run-all-tests #"(reagenttest\.test.*|reagent\..*-test)")) (defmethod test/report [::test/default :summary] [m] ;; ClojureScript 2814 doesn't return anything from run-tests @@ -56,4 +56,4 @@ (run-tests) [#'test-output-mini])) -(doo/doo-all-tests #"reagenttest.test.*") +(doo/doo-all-tests #"(reagenttest\.test.*|reagent\..*-test)")