Test and create form controls using columns

This commit is contained in:
Marcus Kammer 2023-08-12 20:12:37 +02:00
parent 3290cfc1e9
commit 3c4e995641
Signed by: marcuskammer
GPG key ID: C374817BE285268F
2 changed files with 14 additions and 5 deletions

View file

@ -38,12 +38,10 @@
:class "col-form-label"
,label))
(:div :class "col-auto"
(:label :type ,type
(:input :class "form-control"
:type ,type
:id ,id
:class "form-control"))
(:div :class "col-auto"
(:span :class "form-text"
,text)))))))
:placeholder ,placeholder)))))))
(defmacro select-option (&rest rest)
`(spinneret:with-html

View file

@ -6,6 +6,7 @@
(:import-from
:cl-sbt/form
:ctrl
:ctrl-col
:select
:select-option))
@ -83,3 +84,13 @@
(ok (search "class=form-select" result))
(ok (search "size=3" result))
(ok (search "option value=1" result)))))
(deftest test-simple-form-control-cols
(let ((result (spinneret:with-html-string (ctrl-col (:id "exampleFormControlInput1" :label "Email address" :type "email" :placeholder "name@example.com")))))
(testing "Generates correct HTML for a simple form using cols"
(ok (search "for=exampleFormControlInput1" result))
(ok (search "class=col-form-label" result))
(ok (search "type=email" result))
(ok (search "class=form-control" result))
(ok (search "id=exampleFormControlInput1" result))
(ok (search "placeholder=name@example.com" result)))))