Add more tests
This commit is contained in:
parent
c4fc390ace
commit
3e84fbaa5c
4 changed files with 69 additions and 3 deletions
|
@ -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)))
|
||||
|
|
|
@ -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)))
|
||||
|
|
39
tests/component/dropdown.lisp
Normal file
39
tests/component/dropdown.lisp
Normal file
|
@ -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)))))
|
25
tests/component/list-group.lisp
Normal file
25
tests/component/list-group.lisp
Normal file
|
@ -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)))))
|
Loading…
Add table
Reference in a new issue