Add more tests for component/form

This commit is contained in:
Marcus Kammer 2023-12-22 14:11:08 +01:00
parent f7ca1a80f6
commit 5bd5489794
Signed by: marcuskammer
GPG key ID: C374817BE285268F

View file

@ -6,6 +6,10 @@
(:import-from
:dev.metalisp.sbt/component/form
:remove-special-chars
:clean-form-str
:build-name-str
:build-value-str
:build-value-prop-str
:ctrl
:combo
:combo-sm
@ -19,6 +23,22 @@
(testing "Removes all special characters from the string STR except numbers and alphabets."
(ok (string= (remove-special-chars "a1b!@#$%^&*()c2") "a1bc2"))))
(deftest test-clean-form-str
(testing "Cleans a form string for use as a name or identifier."
(ok (string= (clean-form-str " hello WORLD") "hello-world"))))
(deftest test-build-name-str
(testing "Builds a standardized string by adding a 'group-' prefix and applying cleaning functions."
(ok (string= (build-name-str "somename") "group-somename"))))
(deftest test-build-value-str
(testing "Trims leading and trailing spaces from the given value string."
(ok (string= (build-value-str " hello-world ") "hello-world"))))
(deftest test-build-value-prop-str
(testing "Builds a value property string by applying various cleaning functions."
(ok (string= (build-value-prop-str " hello world ") "hello-world"))))
(deftest test-select-default
(let ((result (spinneret:with-html-string (combo () "Red" "Green" "Blue"))))
(testing "Generates correct HTML for select element"