diff --git a/cl-sbt.asd b/cl-sbt.asd index a8dc386..dfe1e4a 100644 --- a/cl-sbt.asd +++ b/cl-sbt.asd @@ -48,6 +48,8 @@ (:file "alert") (:file "badge") (:file "button") - (:file "card")))) + (:file "card") + (:file "dropdown") + (:file "list-group")))) :description "Test system for cl-sbt" :perform (test-op (op c) (symbol-call :rove :run c))) diff --git a/src/component/dropdown.lisp b/src/component/dropdown.lisp index 0a913ea..4937642 100644 --- a/src/component/dropdown.lisp +++ b/src/component/dropdown.lisp @@ -48,7 +48,7 @@ BODY: The text for the dropdown item." `(spinneret:with-html (:li (:a :class "dropdown-item" :href "#" ,@body)))) -(defmacro dropdown ((&key (title "")) &body body) +(defmacro dropdown ((&key (name "")) &body body) "This macro generates a Bootstrap dropdown component. TITLE: The text for the dropdown button. @@ -59,5 +59,5 @@ BODY: The contents of the dropdown, which should be created using the `menu` mac :type "button" :data-bs-toggle "dropdown" :aria-expanded "false" - ,title) + ,name) ,@body))) diff --git a/tests/component/dropdown.lisp b/tests/component/dropdown.lisp new file mode 100644 index 0000000..f6628ab --- /dev/null +++ b/tests/component/dropdown.lisp @@ -0,0 +1,39 @@ +(defpackage cl-sbt/tests/dropdown + (:use + :cl + :cl-sbt + :rove) + (:import-from + :cl-sbt/dropdown + :menu + :item + :dropdown)) + +(in-package :cl-sbt/tests/dropdown) + +(deftest test-menu + (let ((result (spinneret:with-html-string (menu (item "Item 1") (item "Item 2"))))) + (testing "Generates correct HTML for a menu with items" + (ok (search "class=dropdown-menu" result)) + (ok (search "class=dropdown-item" result)) + (ok (search "Item 1" result)) + (ok (search "Item 2" result))))) + +(deftest test-item + (let ((result (spinneret:with-html-string (item "Item 1")))) + (testing "Generates correct HTML for an item" + (ok (search "class=dropdown-item" result)) + (ok (search "Item 1" result))))) + +(deftest test-dropdown + (let ((result (spinneret:with-html-string (dropdown (:name "Dropdown") (menu (item "Item 1") (item "Item 2")))))) + (testing "Generates correct HTML for a dropdown with title and menu" + (ok (search "class=dropdown" result)) + (ok (search "class=\"btn btn-secondary dropdown-toggle\"" result)) + (ok (search "type=button" result)) + (ok (search "data-bs-toggle=dropdown" result)) + (ok (search "aria-expanded=false" result)) + (ok (search "class=dropdown-menu" result)) + (ok (search "class=dropdown-item" result)) + (ok (search "Item 1" result)) + (ok (search "Item 2" result))))) diff --git a/tests/component/list-group.lisp b/tests/component/list-group.lisp new file mode 100644 index 0000000..a0753a3 --- /dev/null +++ b/tests/component/list-group.lisp @@ -0,0 +1,25 @@ +(defpackage cl-sbt/tests/list-group + (:use + :cl + :cl-sbt + :rove) + (:import-from + :cl-sbt/list-group + :item + :list-group)) + +(in-package :cl-sbt/tests/list-group) + +(deftest test-item + (let ((result (spinneret:with-html-string (item "Item 1")))) + (testing "Generates correct HTML for a list group item" + (ok (search "class=list-group-item" result)) + (ok (search "Item 1" result))))) + +(deftest test-list-group + (let ((result (spinneret:with-html-string (list-group (:content "Item 1") (:content "Item 2"))))) + (testing "Generates correct HTML for a list group with items" + (ok (search "class=\"list-group list-group-flush\"" result)) + (ok (search "class=list-group-item" result)) + (ok (search "Item 1" result)) + (ok (search "Item 2" result)))))