|
|
@ -85,9 +85,9 @@
|
|
|
|
:type "text"
|
|
|
|
:type "text"
|
|
|
|
:value nil}])
|
|
|
|
:value nil}])
|
|
|
|
(first
|
|
|
|
(first
|
|
|
|
(nthrest
|
|
|
|
(nthrest
|
|
|
|
(render-widgets def {} {})
|
|
|
|
(render-widgets def {} {})
|
|
|
|
2)))))
|
|
|
|
2)))))
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
:required true
|
|
|
|
:required true
|
|
|
|
:widget :input}}}]
|
|
|
|
:widget :input}}}]
|
|
|
@ -99,9 +99,9 @@
|
|
|
|
:type "text"
|
|
|
|
:type "text"
|
|
|
|
:value nil}])
|
|
|
|
:value nil}])
|
|
|
|
(first
|
|
|
|
(first
|
|
|
|
(nthrest
|
|
|
|
(nthrest
|
|
|
|
(render-widgets def {} {})
|
|
|
|
(render-widgets def {} {})
|
|
|
|
2)))))
|
|
|
|
2)))))
|
|
|
|
(testing "input is default"
|
|
|
|
(testing "input is default"
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
:required true}}}]
|
|
|
|
:required true}}}]
|
|
|
@ -113,9 +113,9 @@
|
|
|
|
:type "text"
|
|
|
|
:type "text"
|
|
|
|
:value nil}])
|
|
|
|
:value nil}])
|
|
|
|
(first
|
|
|
|
(first
|
|
|
|
(nthrest
|
|
|
|
(nthrest
|
|
|
|
(render-widgets def {} {})
|
|
|
|
(render-widgets def {} {})
|
|
|
|
2)))))))
|
|
|
|
2)))))))
|
|
|
|
(testing "checkbox is rendered correctly"
|
|
|
|
(testing "checkbox is rendered correctly"
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
:widget :checkbox}}}]
|
|
|
|
:widget :checkbox}}}]
|
|
|
@ -127,9 +127,9 @@
|
|
|
|
:type "checkbox"
|
|
|
|
:type "checkbox"
|
|
|
|
:value nil}])
|
|
|
|
:value nil}])
|
|
|
|
(first
|
|
|
|
(first
|
|
|
|
(nthrest
|
|
|
|
(nthrest
|
|
|
|
(render-widgets def {} {})
|
|
|
|
(render-widgets def {} {})
|
|
|
|
2)))))
|
|
|
|
2)))))
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
:required true
|
|
|
|
:required true
|
|
|
|
:widget :checkbox}}}]
|
|
|
|
:widget :checkbox}}}]
|
|
|
@ -141,9 +141,9 @@
|
|
|
|
:type "checkbox"
|
|
|
|
:type "checkbox"
|
|
|
|
:value nil}])
|
|
|
|
:value nil}])
|
|
|
|
(first
|
|
|
|
(first
|
|
|
|
(nthrest
|
|
|
|
(nthrest
|
|
|
|
(render-widgets def {} {})
|
|
|
|
(render-widgets def {} {})
|
|
|
|
2))))))
|
|
|
|
2))))))
|
|
|
|
(testing "textarea is rendered correctly"
|
|
|
|
(testing "textarea is rendered correctly"
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
:widget :textarea}}}]
|
|
|
|
:widget :textarea}}}]
|
|
|
@ -154,9 +154,9 @@
|
|
|
|
:required false}
|
|
|
|
:required false}
|
|
|
|
""])
|
|
|
|
""])
|
|
|
|
(first
|
|
|
|
(first
|
|
|
|
(nthrest
|
|
|
|
(nthrest
|
|
|
|
(render-widgets def {} {})
|
|
|
|
(render-widgets def {} {})
|
|
|
|
2)))))
|
|
|
|
2)))))
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
:required true
|
|
|
|
:required true
|
|
|
|
:widget :textarea}}}]
|
|
|
|
:widget :textarea}}}]
|
|
|
@ -167,9 +167,9 @@
|
|
|
|
:required true}
|
|
|
|
:required true}
|
|
|
|
""])
|
|
|
|
""])
|
|
|
|
(first
|
|
|
|
(first
|
|
|
|
(nthrest
|
|
|
|
(nthrest
|
|
|
|
(render-widgets def {} {})
|
|
|
|
(render-widgets def {} {})
|
|
|
|
2))))))
|
|
|
|
2))))))
|
|
|
|
(testing "select is rendered correctly"
|
|
|
|
(testing "select is rendered correctly"
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
:widget :select
|
|
|
|
:widget :select
|
|
|
@ -180,12 +180,12 @@
|
|
|
|
[:select {:id "foo-id"
|
|
|
|
[:select {:id "foo-id"
|
|
|
|
:name "foo-id"}
|
|
|
|
:name "foo-id"}
|
|
|
|
(list
|
|
|
|
(list
|
|
|
|
[:option {:value "key1" :selected false} "value1"]
|
|
|
|
[:option {:value "key1" :selected false} "value1"]
|
|
|
|
[:option {:value "key2" :selected false} "value2"])])
|
|
|
|
[:option {:value "key2" :selected false} "value2"])])
|
|
|
|
(first
|
|
|
|
(first
|
|
|
|
(nthrest
|
|
|
|
(nthrest
|
|
|
|
(render-widgets def {} {})
|
|
|
|
(render-widgets def {} {})
|
|
|
|
2))))))
|
|
|
|
2))))))
|
|
|
|
(testing "hidden is rendered correctly"
|
|
|
|
(testing "hidden is rendered correctly"
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
:widget :hidden}}}]
|
|
|
|
:widget :hidden}}}]
|
|
|
@ -196,9 +196,9 @@
|
|
|
|
:name "foo-id"
|
|
|
|
:name "foo-id"
|
|
|
|
:value nil}])
|
|
|
|
:value nil}])
|
|
|
|
(first
|
|
|
|
(first
|
|
|
|
(nthrest
|
|
|
|
(nthrest
|
|
|
|
(render-widgets def {} {})
|
|
|
|
(render-widgets def {} {})
|
|
|
|
2)))))
|
|
|
|
2)))))
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
:widget :hidden}}}]
|
|
|
|
:widget :hidden}}}]
|
|
|
|
(is (= (list nil
|
|
|
|
(is (= (list nil
|
|
|
@ -208,9 +208,9 @@
|
|
|
|
:name "foo-id"
|
|
|
|
:name "foo-id"
|
|
|
|
:value "4711"}])
|
|
|
|
:value "4711"}])
|
|
|
|
(first
|
|
|
|
(first
|
|
|
|
(nthrest
|
|
|
|
(nthrest
|
|
|
|
(render-widgets def {:foo-id "4711"} {})
|
|
|
|
(render-widgets def {:foo-id "4711"} {})
|
|
|
|
2))))))
|
|
|
|
2))))))
|
|
|
|
(testing "mselect is rendered correctly"
|
|
|
|
(testing "mselect is rendered correctly"
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
:widget :mselect
|
|
|
|
:widget :mselect
|
|
|
@ -223,12 +223,22 @@
|
|
|
|
:size 5
|
|
|
|
:size 5
|
|
|
|
:multiple "multiple"}
|
|
|
|
:multiple "multiple"}
|
|
|
|
(list
|
|
|
|
(list
|
|
|
|
[:option {:value "key1" :selected false} "value1"]
|
|
|
|
[:option {:value "key1" :selected false} "value1"]
|
|
|
|
[:option {:value "key2" :selected false} "value2"])])
|
|
|
|
[:option {:value "key2" :selected false} "value2"])])
|
|
|
|
(first
|
|
|
|
(first
|
|
|
|
(nthrest
|
|
|
|
(nthrest
|
|
|
|
(render-widgets def {} {})
|
|
|
|
(render-widgets def {} {})
|
|
|
|
2)))))))
|
|
|
|
2))))))
|
|
|
|
|
|
|
|
(testing "input-widget uses :attr"
|
|
|
|
|
|
|
|
(let [def {:fields {:foor-id {:attrs {:autofocus true}}}}
|
|
|
|
|
|
|
|
rendered-input (-> (render-widgets def {} {})
|
|
|
|
|
|
|
|
(nthrest 2)
|
|
|
|
|
|
|
|
first
|
|
|
|
|
|
|
|
(nthrest 2)
|
|
|
|
|
|
|
|
first)
|
|
|
|
|
|
|
|
input-attrs (second rendered-input)]
|
|
|
|
|
|
|
|
(contains? input-attrs :autofocus)
|
|
|
|
|
|
|
|
(is (= true (:autofocus input-attrs))))))
|
|
|
|
|
|
|
|
|
|
|
|
(deftest to-form-is-used
|
|
|
|
(deftest to-form-is-used
|
|
|
|
(testing "data passed to fo-form is taken from values"
|
|
|
|
(testing "data passed to fo-form is taken from values"
|
|
|
@ -242,9 +252,9 @@
|
|
|
|
:required false
|
|
|
|
:required false
|
|
|
|
:type "text"}])
|
|
|
|
:type "text"}])
|
|
|
|
(first
|
|
|
|
(first
|
|
|
|
(nthrest
|
|
|
|
(nthrest
|
|
|
|
(render-widgets def {:foo "abc"} {})
|
|
|
|
(render-widgets def {:foo "abc"} {})
|
|
|
|
2)))))
|
|
|
|
2)))))
|
|
|
|
(let [def {:fields {:foo {:label ""
|
|
|
|
(let [def {:fields {:foo {:label ""
|
|
|
|
:to-form (partial str "4711")}}}]
|
|
|
|
:to-form (partial str "4711")}}}]
|
|
|
|
(is (= (list nil
|
|
|
|
(is (= (list nil
|
|
|
@ -255,9 +265,9 @@
|
|
|
|
:required false
|
|
|
|
:required false
|
|
|
|
:type "text"}])
|
|
|
|
:type "text"}])
|
|
|
|
(first
|
|
|
|
(first
|
|
|
|
(nthrest
|
|
|
|
(nthrest
|
|
|
|
(render-widgets def {:foo "abc"} {:params {:foo "def"}})
|
|
|
|
(render-widgets def {:foo "abc"} {:params {:foo "def"}})
|
|
|
|
2)))))))
|
|
|
|
2)))))))
|
|
|
|
|
|
|
|
|
|
|
|
(deftest form-specs-is-applied
|
|
|
|
(deftest form-specs-is-applied
|
|
|
|
(testing "valid spec"
|
|
|
|
(testing "valid spec"
|
|
|
@ -268,10 +278,10 @@
|
|
|
|
:id "__form-hash"
|
|
|
|
:id "__form-hash"
|
|
|
|
:value (form-hash def {})}]
|
|
|
|
:value (form-hash def {})}]
|
|
|
|
(second
|
|
|
|
(second
|
|
|
|
(render-widgets
|
|
|
|
(render-widgets
|
|
|
|
def
|
|
|
|
def
|
|
|
|
{}
|
|
|
|
{}
|
|
|
|
{:params {:__form-hash (form-hash def {})}}))))))
|
|
|
|
{:params {:__form-hash (form-hash def {})}}))))))
|
|
|
|
(testing "invalid spec"
|
|
|
|
(testing "invalid spec"
|
|
|
|
(let [def {:fields {}
|
|
|
|
(let [def {:fields {}
|
|
|
|
:form-specs [(fn [req] false)]}]
|
|
|
|
:form-specs [(fn [req] false)]}]
|
|
|
@ -279,10 +289,10 @@
|
|
|
|
[:h2.flash__heading--error "Warning"]
|
|
|
|
[:h2.flash__heading--error "Warning"]
|
|
|
|
[:p "The form must comply to " (name :clojure.spec.alpha/unknown)]]
|
|
|
|
[:p "The form must comply to " (name :clojure.spec.alpha/unknown)]]
|
|
|
|
(first
|
|
|
|
(first
|
|
|
|
(render-widgets
|
|
|
|
(render-widgets
|
|
|
|
def
|
|
|
|
def
|
|
|
|
{}
|
|
|
|
{}
|
|
|
|
{:params {:__form-hash (form-hash def {})}})))))))
|
|
|
|
{:params {:__form-hash (form-hash def {})}})))))))
|
|
|
|
|
|
|
|
|
|
|
|
(deftest html-contents-are-escaped
|
|
|
|
(deftest html-contents-are-escaped
|
|
|
|
(testing "mselect"
|
|
|
|
(testing "mselect"
|
|
|
|