2023-08-10 18:21:00 +02:00
|
|
|
(defpackage cl-sbt/tests/form
|
|
|
|
(:use
|
|
|
|
:cl
|
|
|
|
:cl-sbt
|
|
|
|
:rove)
|
|
|
|
(:import-from
|
|
|
|
:cl-sbt/form
|
2023-10-08 11:37:04 +02:00
|
|
|
:remove-special-chars
|
2023-08-11 17:39:28 +02:00
|
|
|
:ctrl
|
2023-09-17 15:26:15 +02:00
|
|
|
:combo
|
|
|
|
:combo-sm
|
|
|
|
:combo-lg
|
2023-08-26 09:07:49 +02:00
|
|
|
:search-form
|
2023-09-04 15:02:52 +02:00
|
|
|
:checkable))
|
2023-08-10 18:21:00 +02:00
|
|
|
|
|
|
|
(in-package :cl-sbt/tests/form)
|
|
|
|
|
2023-10-08 11:37:04 +02:00
|
|
|
(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"))))
|
|
|
|
|
2023-08-11 17:39:28 +02:00
|
|
|
(deftest test-select-default
|
2023-09-17 15:26:15 +02:00
|
|
|
(let ((result (spinneret:with-html-string (combo () "Red" "Green" "Blue"))))
|
2023-08-12 12:04:04 +02:00
|
|
|
(testing "Generates correct HTML for select element"
|
|
|
|
(ok (search "class=form-select" result))
|
2023-09-16 16:16:44 +02:00
|
|
|
(ok (search "option value=red" result))
|
|
|
|
(ok (search "option value=green" result))
|
|
|
|
(ok (search "option value=blue" result)))))
|
2023-08-15 19:30:01 +02:00
|
|
|
|
|
|
|
(deftest test-default-search-form
|
2023-08-16 09:30:35 +02:00
|
|
|
(let ((result (spinneret:with-html-string (search-form))))
|
2023-08-15 19:30:01 +02:00
|
|
|
(testing "Generates correct HTML for search form"
|
|
|
|
(ok (search "class=\"form-control me-2\"" result))
|
|
|
|
(ok (search "type=search" result))
|
2023-09-13 15:47:16 +02:00
|
|
|
(ok (search "title=Search" result))
|
2023-08-15 19:30:01 +02:00
|
|
|
(ok (search "type=submit" result))
|
|
|
|
(ok (search "class=\"btn btn-outline-success\"" result))
|
|
|
|
(ok (search "<input" result))
|
|
|
|
(ok (search "<button" result)))))
|
2023-08-26 09:07:49 +02:00
|
|
|
|
2023-09-05 21:01:37 +02:00
|
|
|
(deftest test-checkable
|
2023-09-04 15:02:52 +02:00
|
|
|
(let ((result (spinneret:with-html-string (checkable "radio" "age" "18-24"))))
|
2023-09-05 21:01:37 +02:00
|
|
|
(testing "Generates correct HTML for checkable"
|
2023-09-06 14:30:51 +02:00
|
|
|
(ok (search "class=\"form-check-label group-age\"" result))
|
2023-09-05 21:01:37 +02:00
|
|
|
(ok (search "value=18-24" result))
|
2023-08-26 09:07:49 +02:00
|
|
|
(ok (search "type=radio" result))
|
2023-09-04 15:02:52 +02:00
|
|
|
(ok (search "name=group-age" result)))))
|