|
|
|
@ -186,6 +186,31 @@
|
|
|
|
|
(nthrest
|
|
|
|
|
(render-widgets def {} {})
|
|
|
|
|
2))))))
|
|
|
|
|
(testing "hidden is rendered correctly"
|
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
|
:widget :hidden}}}]
|
|
|
|
|
(is (= (list nil
|
|
|
|
|
[:label {:for "foo-id"} "foo-label"]
|
|
|
|
|
[:input {:id "foo-id"
|
|
|
|
|
:type "hidden"
|
|
|
|
|
:name "foo-id"
|
|
|
|
|
:value nil}])
|
|
|
|
|
(first
|
|
|
|
|
(nthrest
|
|
|
|
|
(render-widgets def {} {})
|
|
|
|
|
2)))))
|
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
|
:widget :hidden}}}]
|
|
|
|
|
(is (= (list nil
|
|
|
|
|
[:label {:for "foo-id"} "foo-label"]
|
|
|
|
|
[:input {:id "foo-id"
|
|
|
|
|
:type "hidden"
|
|
|
|
|
:name "foo-id"
|
|
|
|
|
:value "4711"}])
|
|
|
|
|
(first
|
|
|
|
|
(nthrest
|
|
|
|
|
(render-widgets def {:foo-id "4711"} {})
|
|
|
|
|
2))))))
|
|
|
|
|
(testing "mselect is rendered correctly"
|
|
|
|
|
(let [def {:fields {:foo-id {:label "foo-label"
|
|
|
|
|
:widget :mselect
|
|
|
|
@ -204,3 +229,32 @@
|
|
|
|
|
(nthrest
|
|
|
|
|
(render-widgets def {} {})
|
|
|
|
|
2)))))))
|
|
|
|
|
|
|
|
|
|
(deftest to-form-is-used
|
|
|
|
|
(testing "data passed to fo-form is taken from values"
|
|
|
|
|
(let [def {:fields {:foo {:label ""
|
|
|
|
|
:to-form (partial str "4711")}}}]
|
|
|
|
|
(is (= (list nil
|
|
|
|
|
[:label {:for "foo"} ""]
|
|
|
|
|
[:input {:id "foo"
|
|
|
|
|
:name "foo"
|
|
|
|
|
:value "4711abc"
|
|
|
|
|
:required false
|
|
|
|
|
:type "text"}])
|
|
|
|
|
(first
|
|
|
|
|
(nthrest
|
|
|
|
|
(render-widgets def {:foo "abc"} {})
|
|
|
|
|
2)))))
|
|
|
|
|
(let [def {:fields {:foo {:label ""
|
|
|
|
|
:to-form (partial str "4711")}}}]
|
|
|
|
|
(is (= (list nil
|
|
|
|
|
[:label {:for "foo"} ""]
|
|
|
|
|
[:input {:id "foo"
|
|
|
|
|
:name "foo"
|
|
|
|
|
:value "4711abc"
|
|
|
|
|
:required false
|
|
|
|
|
:type "text"}])
|
|
|
|
|
(first
|
|
|
|
|
(nthrest
|
|
|
|
|
(render-widgets def {:foo "abc"} {:params {:foo "def"}})
|
|
|
|
|
2)))))))
|
|
|
|
|