(defpackage dev.metalisp.sbt/tests/form (:use :cl :dev.metalisp.sbt :rove) (: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 :combo-lg :search-form :checkable)) (in-package :dev.metalisp.sbt/tests/form) (deftest test-remove-special-chars (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" (ok (search "class=form-select" result)) (ok (search "option value=red" result)) (ok (search "option value=green" result)) (ok (search "option value=blue" result))))) (deftest test-default-search-form (let ((result (spinneret:with-html-string (search-form)))) (testing "Generates correct HTML for search form" (ok (search "class=\"form-control me-2\"" result)) (ok (search "type=search" result)) (ok (search "title=Search" result)) (ok (search "type=submit" result)) (ok (search "class=\"btn btn-outline-success\"" result)) (ok (search "